1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e5+7;
vector<pair<int,int>>V[2*LIM];
ll T[LIM][2], mi[8*LIM], ile[8*LIM][11], ans[11], sum[8*LIM], N=1, n;
void jeden(int a, int b, int c, int d) {
  int x=-1, y=2*n;
  if(b<a) x=max(x, b);
  else y=min(y, b);
  if(c<a) x=max(x, c);
  else y=min(y, c);
  if(d<a) x=max(x, d);
  else y=min(y, d);
  V[y-1].pb({x+1, 1});
  if(a+1<=y-1) V[y-1].pb({a+1, -1});
  if(x+1<=a-1) V[a-1].pb({x+1, -1});
}
void dwa(int a, int c, int b, int d) {
  if(a>c) swap(a, c);
  if(a<b && b<c || a<d && d<c) return;
  if(b>d) swap(b, d);
  if(c<b) {
    d=b;
    b=-1;
  } else if(d<a) {
    b=d;
    d=2*n;
  }
  V[d-1].pb({b+1, 1});
  V[c-1].pb({b+1, -1});
  V[d-1].pb({a+1, -1});
  if(a+1<=c-1) V[c-1].pb({a+1, 1});
}
void lacz(int v) {
  mi[v]=min(mi[2*v], mi[2*v+1]+sum[2*v]);
  sum[v]=sum[2*v]+sum[2*v+1];
  int r=abs(mi[2*v+1]+sum[2*v]-mi[2*v]);
  if(mi[2*v]<=mi[2*v+1]+sum[2*v]) {
    rep(i, 11) ile[v][i]=ile[2*v][i];
    rep(i, 11) if(i+r<11) ile[v][i+r]+=ile[2*v+1][i];
  } else {
    rep(i, 11) ile[v][i]=ile[2*v+1][i];
    rep(i, 11) if(i+r<11) ile[v][i+r]+=ile[2*v][i];
  }
}
void upd(int v, ll x) {
  v+=N;
  sum[v]+=x;
  mi[v]+=x;
  v/=2;
  while(v) {
    lacz(v);
    v/=2;
  }
}
void cnt(int l, int r) {
  l+=N; r+=N;
  vector<int>A, B;
  A.pb(l);
  if(l<r) B.pb(r);
  while(l/2!=r/2) {
    if(l%2==0) A.pb(l+1);
    if(r%2==1) B.pb(r-1);
    l/=2; r/=2;
  }
  reverse(all(B));
  for(auto i : B) A.pb(i);
  ll aktsum=0;
  for(auto i : A) {
    rep(j, 11) if(mi[i]+aktsum+j<11) ans[mi[i]+aktsum+j]+=ile[i][j];
    aktsum+=sum[i];
  }
}
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int k;
  cin >> n >> k;
  while(N<2*n) N*=2;
  rep(i, 2) rep(j, n) {
    cin >> T[j][i]; --T[j][i];
  }
  rep(i, n) {
    jeden(T[i][0], T[i][1], T[(i+1)%n][0], T[(i+1)%n][1]);
    jeden(T[i][1], T[i][0], T[(i+1)%n][0], T[(i+1)%n][1]);
    dwa(T[i][0], T[(i+1)%n][1], T[i][1], T[(i+1)%n][0]);
    dwa(T[i][1], T[(i+1)%n][0], T[i][0], T[(i+1)%n][1]);
    dwa(T[i][0], T[i][1], T[(i+1)%n][0], T[(i+1)%n][1]);
  }
  rep(i, 2*n) for(auto j : V[i]) sum[N+j.st]+=j.nd;
  rep(i, N) {
    mi[N+i]=sum[N+i];
    ile[N+i][0]=1;
  }
  for(int i=N-1; i; --i) lacz(i);
  rep(i, 2*n) {
    cnt(0, i);
    for(auto j : V[i]) upd(j.st, -j.nd);
  }
  ans[1]+=ans[0];
  rep(i, k) cout << ans[i+1] << " ";
  cout << '\n';
}