#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<iomanip>
#include<iterator>
#include <cstdio>
#include <vector>
#include <string>
#include <regex>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include<utility>
#include<random>
#include<bitset>
#include<list>
#include<functional>
using namespace std;
template<class T, typename A = allocator<T>>
class Vector : public vector<T, A>
{
public:
	using vector<T, A>::vector;
	Vector& operator()(size_t dummy_n) // additional init_val needs its own specification for Vector<string>
	{
		return *this;
	}
};
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef Vector<int> vi; // Vector
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pdd> vpdd;
typedef vector<string> vs;
typedef set<int> si;
typedef multiset<int> Si;
typedef map<int, int> mi;
typedef multimap<int, int> Mi;
template <typename Int = int>
Int read()
{
	Int flag = 1;
	char c = getchar();
	while ((c < '0' || c > '9') && c != '-' && c != EOF) c = getchar();
	if (c == '-') flag = -1, c = getchar();
	Int init = c & 15;
	while ((c = getchar()) >= '0' && c <= '9') init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}
void read(char& a) { do scanf("%c", &a); while (isspace(a)); }
void write(const char& a) { printf("%c", a); }
char BUF[1234560];
void read(string& a) { scanf("%s", BUF); a = string(BUF); }
void write(const string& a) { printf("%s", a.c_str()); }
inline void read(int& a) { /*scanf("%d", &a);*/a = read(); }
void write(const int& a) { printf("%d", a); }
//void write(const size_t& a) { printf("%u", a); }
void read(ll& a) { scanf("%I64d", &a); }
void write(const ll& a) { printf("%I64d", a); }
void read(double& a) { scanf("%lf", &a); }
void write(const double& a) { printf("%lf", a); }
void read(ld& a) { scanf("%Lf", &a); }
void write(const ld& a) { printf("%Lf", a); }
void read(pair<int, int>& a) { scanf("%d%d", &a.first, &a.second); }
void write(const pair<int, int>& a) { printf("%d %d", a.first, a.second); }
template<template<typename T, typename A = allocator<T> > class C, class T>
void read(C<T>& a) { for (auto i = a.begin(); i != a.end(); ++i) read(*i); }
template<template<typename T, typename A = allocator<T> > class C, class T>
void write(const C<T>& a) { int sz = a.size(); if (sz != 0) write(a[0]); for (int i = 1; i < sz; ++i) { write(' '); write(a[i]); } }
template<typename T1, typename T2>
void read(T1& t1, T2& t2) { read(t1); read(t2); }
template<typename T1, typename T2>
void write(const T1& t1, const T2& t2) { write(t1); write(' '); write(t2); }
template<typename T1, typename T2, typename T3>
void read(T1& t1, T2& t2, T3& t3) { read(t1); read(t2); read(t3); }
template<typename T1, typename T2, typename T3, typename T4>
void read(T1& t1, T2& t2, T3& t3, T4& t4) { read(t1); read(t2); read(t3); read(t4); }
template<typename T1, typename T2, typename T3>
void write(const T1& t1, const T2& t2, const T3& t3) { write(t1); write(' '); write(t2); write(' '); write(t3); }
template<template<typename T, typename A = allocator<T> > class C, class T>
void sort(C<T>& a) { sort(a.begin(), a.end()); }
void sort(string& a) { sort(a.begin(), a.end()); }
template<template<typename T, typename A = allocator<T> > class C, class T>
void rsort(C<T>& a) { sort(a.rbegin(), a.rend()); }
void rsort(string& a) { sort(a.rbegin(), a.rend()); }
template<typename T>
int sz(const T& a) { return int(a.size()); }
#define MX 1000000000
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define T(n) for(int _VARIABLE{(n) + 1}; --_VARIABLE;)
#define F(b,e,i) for(auto i = (b); i != (e); (b) < decltype(b)(e) ? ++i : --i)
#define G(f,l,i) for(auto i = (f) + ((f) < decltype(f)(l) ? -1 : 1); ((f) < decltype(f)(l) ? i++ : i--) != (l) ;)
#define M(f,l,i,j) for(auto i = (f) , j = decltype(f)(l) ; i < j; ++i, --j)
#define r(...) read(__VA_ARGS__)
#define R(type, ...) type __VA_ARGS__; r(__VA_ARGS__)
#define w(...) write(__VA_ARGS__)
#define W(...) write(__VA_ARGS__), write('\n')
#define bgn begin()
#define rbgn rbegin()
#define nd end()
#define rnd rend()
#define pb push_back
#define fnt front()
#define bck back()
#define x first
#define y second

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
	int n{ r() };
	vi a, b; a.reserve(n); b.reserve(n);
	{
		T(n) a.pb(r());
		T(n) b.pb(r());
	}
	vi name_to_ind(n + 1);
	{
		int i{ -1 };
		for (const auto& a_el : a)
			name_to_ind[a_el] = ++i;
	}
	vi ans; ans.reserve(n);
	{
		int l{ -1 };
		for (const auto& b_el : b)
			if (int wh{ name_to_ind[b_el] }; wh > l) {
				ans.pb(wh - l);
				l = wh;
			}
			else
				ans.pb(0);
	}
	W(ans);
}
//
// ArtemParkhomets
//


#include<bits/stdc++.h>

using namespace std;

int n;
int a[20001], mark[20001], b, ans=0, x[20001];

int main()
{
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin >> n;

for(int i=0; i<n; i++)
   {
        cin >> a[i];
        x[a[i]] = i ;

        cout << " a[i] is "<< a[i] <<" x[a[i]] is " << x[a[i]] << endl;
   }

for( int i=0; i<n; i++)
{
    cin >> b;
    ans = 0;
    int j = x[b];

    while( !mark[j] && j-1>=0 )
    {
        ans++;
        mark[j]=1;
        j --;
    }
    if(i)
    cout << ans << " ";
    else
    cout << ans+1 << " ";
}
return 0;
}


#include<bits/stdc++.h>

using namespace std;

int n;
int a[20001], mark[20001], b, ans=0, x[20001];

int main()
{
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin >> n;

for(int i=0; i<n; i++)
   {
        cin >> a[i];
        x[a[i]] = i ;

        //cout << " a[i] is "<< a[i] <<" x[a[i]] is " << x[a[i]] << endl;
   }

for( int i=0; i<n; i++)
{
    cin >> b;
    ans = 0;
    int j = x[b];

    while( !mark[j] && j-1>=0 )
    {
        ans++;
        mark[j]=1;
        j --;
    }
    if(i)
    cout << ans << " ";
    else
    cout << ans+1 << " ";
}
return 0;
}


#include<bits/stdc++.h>

using namespace std;

 long int n, ans=0, p=0, z=0, k=0;
   bool flag;
int main()
{
cin >> n;
long int a[n], b[n];
long int i;

for( long int u=0; u<n; u++ )
    cin >> a[u];

for( long int u=0; u<n; u++)
     cin >> b[u];

//////////////////////////////////////////////////
for( i=0; i<n; i++)
{

    if( flag != 1 && i!=0 )
    {
     cout << "0 ";
    z = k;
    }
    else
    k = z;
       if( k == n )
    {
        cout << "0 ";
        continue;
    }

    flag = 0;

    ans = 0;
    if( z != n )
    {

        for(long int u=z; u<n; u++)
         {
             if ( b[i] == a[u] )
             {
                 //cout << " hello   b[i] is "<< b[i] << "   a[u] is " << a[u] << " ans is ";
                 ans ++;
                 z++;
                 cout << ans <<' ';
                 //cout << ans << "   z is " <<z << "   ";
                 flag = 1;

                 break;
             }
             else
             {
                ans++;
                z++;
                //cout << endl << " goodbye   " << "b[i] is "<< b[i] << "   a[u] is " << a[u] << " ans is "<< ans << "  z is  " << z;
             }
         }
   }
//    else
//    cout << " 0 ";
}
return 0;
}


#include<bits/stdc++.h>

using namespace std;

long long int n;
long long int a[1000000], mark[1000000], b, ans=0, x[1000000];

int main()
{
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin >> n;

for(int i=0; i<n; i++)
   {
        cin >> a[i];
        x[a[i]] = i ;

        //cout << " a[i] is "<< a[i] <<" x[a[i]] is " << x[a[i]] << endl;
   }

for( int i=0; i<n; i++)
{
    cin >> b;
    ans = 0;
    int j = x[b];

    while( !mark[j] && j-1>=0 )
    {
        ans++;
        mark[j]=1;
        j --;
    }
    if(i)
    cout << ans << " ";
    else
    cout << ans+1 << " ";
}
return 0;
}


#include<bits/stdc++.h>

using namespace std;

 long int n, ans=0, p=0, z=0, k=0;
   bool flag;
int main()
{
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin >> n;
long int a[n], b[n];
long int i;

for( long int u=0; u<n; u++ )
    cin >> a[u];

for( long int u=0; u<n; u++)
     cin >> b[u];

//////////////////////////////////////////////////
for( i=0; i<n; i++)
{

    if( flag != 1 && i!=0 )
    {
     cout << "0 ";
    z = k;
    }
    else
    k = z;
       if( k == n )
    {
        cout << "0 ";
        continue;
    }

    flag = 0;

    ans = 0;
    if( z != n )
    {

        for(long int u=z; u<n; u++)
         {
             if ( b[i] == a[u] )
             {
                 //cout << " hello   b[i] is "<< b[i] << "   a[u] is " << a[u] << " ans is ";
                 ans ++;
                 z++;
                 cout << ans <<' ';
                 //cout << ans << "   z is " <<z << "   ";
                 flag = 1;

                 break;
             }
             else
             {
                ans++;
                z++;
                //cout << endl << " goodbye   " << "b[i] is "<< b[i] << "   a[u] is " << a[u] << " ans is "<< ans << "  z is  " << z;
             }
         }
   }
//    else
//    cout << " 0 ";
}
return 0;
}


#include<bits/stdc++.h>

using namespace std;

long long int n;
long long int a[20001], mark[20001], b, ans=0, x[1000000];

int main()
{
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin >> n;

for(int i=0; i<n; i++)
   {
        cin >> a[i];
        x[a[i]] = i ;

        //cout << " a[i] is "<< a[i] <<" x[a[i]] is " << x[a[i]] << endl;
   }

for( int i=0; i<n; i++)
{
    cin >> b;
    ans = 0;
    int j = x[b];

    while( !mark[j] && j-1>=0 )
    {
        ans++;
        mark[j]=1;
        j --;
    }
    if(i)
    cout << ans << " ";
    else
    cout << ans+1 << " ";
}
return 0;
}


#include<bits/stdc++.h>

using namespace std;

int n;
int a[20001], mark[20001], b, ans=0, x[1000000];

int main()
{
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin >> n;

for(int i=0; i<n; i++)
   {
        cin >> a[i];
        x[a[i]] = i ;

        //cout << " a[i] is "<< a[i] <<" x[a[i]] is " << x[a[i]] << endl;
   }

for( int i=0; i<n; i++)
{
    cin >> b;
    ans = 0;
    int j = x[b];

    while( !mark[j] && j-1>=0 )
    {
        ans++;
        mark[j]=1;
        j --;
    }
    if(i)
    cout << ans << " ";
    else
    cout << ans+1 << " ";
}
return 0;
}


//1915001 Debojyoti Das NIT Silchar
//Jai Mata Di
//FOR MA and BABA
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(l i=0;i<n;i++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define l long long int
#define si(x)	cin>>x
#define ss(s)	cin>>s
#define pi(x)	cout<<x<<" "
#define pl(x)	cout<<x<<endl
#define ps(s)	cout<<s
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define pf push_front
#define popb pop_back
#define popf pop_front
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define nl cout << endl
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<l, l>	pl;
typedef vector<int>		vi;
typedef vector<l>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, l m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const l mod = 1000000007;
const l N = 3e5, M = N;
vi g[N];
l a[N];
l mpow(l base,l exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((l)result * base) % mod;
    base = ((l)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(l n, l m){
	l i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}
int sgn(l n){
    if(n>0){
        return 1;
    }
    else{
        return -1;
    }
}
l max_digit(l n){
    l lar=0;
while(n){
    l r=n%10;
    lar=max(r,lar);
    n=n/10;
}
return lar;
}
l min_digit(l n){
    l lar=9;
while(n){
    l r=n%10;
    lar=min(r,lar);
    n=n/10;
}
return lar;
}
int prime(l n){
for(l i=2;i<n;i++){
    if(n%i==0){
   return 0;
    }
}
    return 1;
}
void dfs(l u, l par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}
int per(l n){
if((l)sqrt(n)==(double)sqrt(n)){
    return 1;
}
return 0;
}
int vowel(char c){
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    return 1;
}
 return 0;
}
//=======================

void solve(){
l n;
cin>>n;
vl v(n),b(n);
fo(i,n)cin>>v[i];
fo(j,n)cin>>b[j];
fo(i,n){
    auto f=find(v.begin(),v.end(),b[i]);
   if(f==v.end())cout<<0<<" ";
   else{
    cout<<f-v.begin()+1<<" ";
    v.erase(v.begin(),f+1);

   }
}
}

int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
    //    cin>>t;
        for(l i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


//1915001 Debojyoti Das NIT Silchar
//Jai Mata Di
//FOR MA and BABA
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(l i=0;i<n;i++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define l long long int
#define si(x)	cin>>x
#define ss(s)	cin>>s
#define pi(x)	cout<<x<<" "
#define pl(x)	cout<<x<<endl
#define ps(s)	cout<<s
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define pf push_front
#define popb pop_back
#define popf pop_front
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define nl cout << endl
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<l, l>	pl;
typedef vector<int>		vi;
typedef vector<l>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, l m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const l mod = 1000000007;
const l N = 3e5, M = N;
vi g[N];
l a[N];
l mpow(l base,l exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((l)result * base) % mod;
    base = ((l)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(l n, l m){
	l i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}
int sgn(l n){
    if(n>0){
        return 1;
    }
    else{
        return -1;
    }
}
l max_digit(l n){
    l lar=0;
while(n){
    l r=n%10;
    lar=max(r,lar);
    n=n/10;
}
return lar;
}
l min_digit(l n){
    l lar=9;
while(n){
    l r=n%10;
    lar=min(r,lar);
    n=n/10;
}
return lar;
}
int prime(l n){
for(l i=2;i<n;i++){
    if(n%i==0){
   return 0;
    }
}
    return 1;
}
void dfs(l u, l par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}
int per(l n){
if((l)sqrt(n)==(double)sqrt(n)){
    return 1;
}
return 0;
}
int vowel(char c){
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    return 1;
}
 return 0;
}
//=======================

void solve(){
l n;
cin>>n;
vl v(n),b(n);
fo(i,n)cin>>v[i];
fo(j,n)cin>>b[j];
//l L=0;
//fo(i,n){
//    if(v.empty()){
//        cout<<0<<" ";
//    }
//    else{
//        auto f=find(v.begin()+L,v.end(),b[i]);
//   if(f==v.end())cout<<0<<" ";
//   else{
//    cout<<f-v.begin()+1-L<<" ";
////    v.erase(v.begin(),f+1);
//    L=f-v.begin()+1;
//   }
//}
//    }
l uti[n+2]{};
l pos=0;
for(l i=0;i<n;i++){
    l x=b[i];
    if(uti[x]){
        cout<<"0 ";
        continue;
    }

    l c=0;
    while(1){
            ++c;
        uti[v[pos]]=1;
        if(v[pos]==x){
        break;
        }
        ++pos;
    }
    cout<<c<<" ";
    ++pos;
}
}

int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
    //    cin>>t;
        for(l i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


//1915001 Debojyoti Das NIT Silchar
//Jai Mata Di
//FOR MA and BABA
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(l i=0;i<n;i++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define l long long int
#define si(x)	cin>>x
#define ss(s)	cin>>s
#define pi(x)	cout<<x<<" "
#define pl(x)	cout<<x<<endl
#define ps(s)	cout<<s
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define pf push_front
#define popb pop_back
#define popf pop_front
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define nl cout << endl
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<l, l>	pl;
typedef vector<int>		vi;
typedef vector<l>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, l m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const l mod = 1000000007;
const l N = 3e5, M = N;
vi g[N];
l a[N];
l mpow(l base,l exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((l)result * base) % mod;
    base = ((l)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(l n, l m){
	l i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}
int sgn(l n){
    if(n>0){
        return 1;
    }
    else{
        return -1;
    }
}
l max_digit(l n){
    l lar=0;
while(n){
    l r=n%10;
    lar=max(r,lar);
    n=n/10;
}
return lar;
}
l min_digit(l n){
    l lar=9;
while(n){
    l r=n%10;
    lar=min(r,lar);
    n=n/10;
}
return lar;
}
int prime(l n){
for(l i=2;i<n;i++){
    if(n%i==0){
   return 0;
    }
}
    return 1;
}
void dfs(l u, l par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}
int per(l n){
if((l)sqrt(n)==(double)sqrt(n)){
    return 1;
}
return 0;
}
int vowel(char c){
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    return 1;
}
 return 0;
}
//=======================

void solve(){
l n;
cin>>n;
vl v(n),b(n);
fo(i,n)cin>>v[i];
fo(j,n)cin>>b[j];
v.pb(0);
b.pb(0);
fo(i,n){
    auto f=find(v.begin(),v.end(),b[i]);
   if(f==v.end())cout<<0<<" ";
   else{
    cout<<f-v.begin()+1<<" ";
    v.erase(v.begin(),f+1);

   }
}
}

int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
    //    cin>>t;
        for(l i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


//1915001 Debojyoti Das NIT Silchar
//Jai Mata Di
//FOR MA and BABA
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(l i=0;i<n;i++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define l long long int
#define si(x)	cin>>x
#define ss(s)	cin>>s
#define pi(x)	cout<<x<<" "
#define pl(x)	cout<<x<<endl
#define ps(s)	cout<<s
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define pf push_front
#define popb pop_back
#define popf pop_front
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define nl cout << endl
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<l, l>	pl;
typedef vector<int>		vi;
typedef vector<l>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, l m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const l mod = 1000000007;
const l N = 3e5, M = N;
vi g[N];
l a[N];
l mpow(l base,l exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((l)result * base) % mod;
    base = ((l)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(l n, l m){
	l i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}
int sgn(l n){
    if(n>0){
        return 1;
    }
    else{
        return -1;
    }
}
l max_digit(l n){
    l lar=0;
while(n){
    l r=n%10;
    lar=max(r,lar);
    n=n/10;
}
return lar;
}
l min_digit(l n){
    l lar=9;
while(n){
    l r=n%10;
    lar=min(r,lar);
    n=n/10;
}
return lar;
}
int prime(l n){
for(l i=2;i<n;i++){
    if(n%i==0){
   return 0;
    }
}
    return 1;
}
void dfs(l u, l par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}
int per(l n){
if((l)sqrt(n)==(double)sqrt(n)){
    return 1;
}
return 0;
}
int vowel(char c){
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    return 1;
}
 return 0;
}
//=======================

void solve(){
l n;
cin>>n;
vl v(n),b(n);
fo(i,n)cin>>v[i];
fo(j,n)cin>>b[j];
l L=0;
fo(i,n){
    if(v.empty()){
        cout<<0<<" ";
    }
    else{
        auto f=find(v.begin()+L,v.end(),b[i]);
   if(f==v.end())cout<<0<<" ";
   else{
    cout<<f-v.begin()+1-L<<" ";
//    v.erase(v.begin(),f+1);
    L=f-v.begin()+1;
   }
}
    }
}

int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
    //    cin>>t;
        for(l i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


//1915001 Debojyoti Das NIT Silchar
//Jai Mata Di
//FOR MA and BABA
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(l i=0;i<n;i++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define l long long int
#define si(x)	cin>>x
#define ss(s)	cin>>s
#define pi(x)	cout<<x<<" "
#define pl(x)	cout<<x<<endl
#define ps(s)	cout<<s
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define pf push_front
#define popb pop_back
#define popf pop_front
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define nl cout << endl
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<l, l>	pl;
typedef vector<int>		vi;
typedef vector<l>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, l m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const l mod = 1000000007;
const l N = 3e5, M = N;
vi g[N];
l a[N];
l mpow(l base,l exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((l)result * base) % mod;
    base = ((l)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(l n, l m){
	l i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}
int sgn(l n){
    if(n>0){
        return 1;
    }
    else{
        return -1;
    }
}
l max_digit(l n){
    l lar=0;
while(n){
    l r=n%10;
    lar=max(r,lar);
    n=n/10;
}
return lar;
}
l min_digit(l n){
    l lar=9;
while(n){
    l r=n%10;
    lar=min(r,lar);
    n=n/10;
}
return lar;
}
int prime(l n){
for(l i=2;i<n;i++){
    if(n%i==0){
   return 0;
    }
}
    return 1;
}
void dfs(l u, l par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}
int per(l n){
if((l)sqrt(n)==(double)sqrt(n)){
    return 1;
}
return 0;
}
int vowel(char c){
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    return 1;
}
 return 0;
}
//=======================

void solve(){
l n;
cin>>n;
vl v(n),b(n);
fo(i,n)cin>>v[i];
fo(j,n)cin>>b[j];
//l L=0;
//fo(i,n){
//    if(v.empty()){
//        cout<<0<<" ";
//    }
//    else{
//        auto f=find(v.begin()+L,v.end(),b[i]);
//   if(f==v.end())cout<<0<<" ";
//   else{
//    cout<<f-v.begin()+1-L<<" ";
////    v.erase(v.begin(),f+1);
//    L=f-v.begin()+1;
//   }
//}
//    }
bool uti[n+2];
l pos=0;
for(l i=0;i<n;i++){
    l x=b[i];
    if(uti[x]){
        cout<<"0 ";
        continue;
    }

    l c=0;
    while(1){
            ++c;
        uti[v[pos]]=true;
        if(v[pos]==x){
        break;
        }
        ++pos;
    }
    cout<<c<<" ";
    ++pos;
}
}

int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
    //    cin>>t;
        for(l i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


//1915001 Debojyoti Das NIT Silchar
//Jai Mata Di
//FOR MA and BABA
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(l i=0;i<n;i++)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define l long long int
#define si(x)	cin>>x
#define ss(s)	cin>>s
#define pi(x)	cout<<x<<" "
#define pl(x)	cout<<x<<endl
#define ps(s)	cout<<s
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define pf push_front
#define popb pop_back
#define popf pop_front
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define nl cout << endl
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<l, l>	pl;
typedef vector<int>		vi;
typedef vector<l>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, l m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const l mod = 1000000007;
const l N = 3e5, M = N;
vi g[N];
l a[N];
l mpow(l base,l exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((l)result * base) % mod;
    base = ((l)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(l n, l m){
	l i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}
int sgn(l n){
    if(n>0){
        return 1;
    }
    else{
        return -1;
    }
}
l max_digit(l n){
    l lar=0;
while(n){
    l r=n%10;
    lar=max(r,lar);
    n=n/10;
}
return lar;
}
l min_digit(l n){
    l lar=9;
while(n){
    l r=n%10;
    lar=min(r,lar);
    n=n/10;
}
return lar;
}
int prime(l n){
for(l i=2;i<n;i++){
    if(n%i==0){
   return 0;
    }
}
    return 1;
}
void dfs(l u, l par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}
int per(l n){
if((l)sqrt(n)==(double)sqrt(n)){
    return 1;
}
return 0;
}
int vowel(char c){
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    return 1;
}
 return 0;
}
//=======================

void solve(){
l n;
cin>>n;
vl v(n),b(n);
fo(i,n)cin>>v[i];
fo(j,n)cin>>b[j];
fo(i,n){
    if(v.empty()){
        cout<<0<<" ";
    }
    else{
        auto f=find(v.begin(),v.end(),b[i]);
   if(f==v.end())cout<<0<<" ";
   else{
    cout<<f-v.begin()+1<<" ";
    v.erase(v.begin(),f+1);

   }
}
    }
}

int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
    //    cin>>t;
        for(l i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    int n,a[200010],p=0,cnt=0;
    bool f = false;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<n;i++)
    {   cnt = 1;
        f = false;
        int b;
        cin >> b;
        for(int j=p;j<n;j++)
        {
            if(a[j] == b)
            {
                cout << cnt << " ";
                f = true;
                p = j+1;
                break;
            }
            else
            {
                cnt++;
            }
        }
        if (!f)
        {
           cout << "0 ";
        }
    }
    return 0;
}


#include <iostream>

using namespace std;
bool mrk[200010];
int main()
{
    ios::sync_with_stdio(0);
    int n,a[200010],p=0,cnt=0;

    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<n;i++)
    {   cnt = 1;
        int b;
        cin >> b;
        if(mrk[b])
        {
            cout << "0 ";
            continue;
        }
        for(int j=p;j<n;j++)
        {
            if(a[j] == b)
            {
                cout << cnt << " ";
                p = j+1;
                break;
            }
            else
            {
                mrk[a[j]] = true;
                cnt++;
            }
        }
    }
    return 0;
}


#include <iostream>
#include<vector>

using namespace std;

int main()
{

    vector <long long> vee;
    long long n;
    long long a[200001];
    cin>>n;
    for(long long i=0;i<n;i++)
    {
        long long x;
        cin>>x;
        vee.push_back(x);
    }
    bool eq = false;
    for(long long i=0;i<n;i++)
    {   eq = false;
        cin >> a[i];
        for(long long j = 0;j<vee.size();j++)
        {
            if(vee[j] == a[i])
            {
                if(vee.size() == 1)
                {
                    cout << j+1;
                    eq = true;
                    return 0;
                }
                cout << j+1 <<" ";
                vee.erase(vee.begin(),vee.begin()+j+1);
                eq = true;
                break;
            }
        }
        if(!eq)
        {
            cout << 0 << " ";
        }

    }

    return 0;
}


#include <iostream>
#include<vector>

using namespace std;

int main()
{

    vector <long long> vee;
    long long n;
    long long a[200001];
    cin>>n;
    for(long long i=0;i<n;i++)
    {
        long long x;
        cin>>x;
        vee.push_back(x);
    }
    bool eq = false;
    for(long long i=0;i<n;i++)
    {   eq = false;
        cin >> a[i];
        for(long long j = 0;j<vee.size();j++)
        {
            if(vee[j] == a[i])
            {
                if(vee.size() == 1)
                {
                    cout << j+1;
                    eq = true;
                    break;
                }
                cout << j+1 <<" ";
                vee.erase(vee.begin(),vee.begin()+j+1);
                eq = true;
                break;
            }
        }
        if(!eq)
        {
            cout << 0 << " ";
        }

    }

    return 0;
}


#include <iostream>
#include<vector>

using namespace std;

int main()
{

    vector <long int> vee;
    long int n,a[200001];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        long int x;
        cin>>x;
        vee.push_back(x);
    }
    bool eq = false;
    for(long int i=0;i<n;i++)
    {   eq = false;
        cin >> a[i];
        for(long int j = 0;j<vee.size();j++)
        {
            if(vee[j] == a[i])
            {
                if(vee.size() == 1)
                {
                    cout << j+1;
                    eq = true;
                    return 0;
                }
                cout << j+1 <<" ";
                vee.erase(vee.begin(),vee.begin()+j+1);
                eq = true;
                break;
            }
        }
        if(!eq)
        {
            cout << 0 << " ";
        }

    }

    return 0;
}


#include <iostream>
#include<vector>

using namespace std;

int main()
{

    vector <int> vee;
    int n,a[200001];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        vee.push_back(x);
    }
    int counter=0;
    bool eq = false;
    for(int i=0;i<n;i++)
    {   eq = false;
        cin >> a[i];
        for(int j = 0;j<vee.size();j++)
        {
            if(vee[j] == a[i])
            {
                if(vee.size() == 1)
                {
                    cout << j+1;
                    eq = true;
                    return 0;
                }
                cout << j+1 <<" ";
                vee.erase(vee.begin(),vee.begin()+j+1);
                eq = true;
                break;
            }
        }
        if(!eq)
        {
            cout << 0 << " ";
        }

    }

    return 0;
}


#include<bits/stdc++.h>

#define ll long long
#define inf 0x3f3f3f3f
#define debug(a,b) cout<<a<<" "<<b<<endl;
using namespace std;
const int N=2e5+10;
int mp[N];
int main()
{

    int n,x;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        mp[x]=i;
    }
    int i=0;
    for(int j=0;j<n;j++)
    {
        cin>>x;
        if(mp[x]<i) cout<<0<<' ';
        else
        {
            int  y=mp[x]-i+1;
            cout<<y<<' ';
            i=mp[x]+1;
        }
    }
    return 0;
}
/*
1+4+9
*/


#include<bits/stdc++.h>

#define ll long long
#define inf 0x3f3f3f3f
#define debug(a,b) cout<<a<<" "<<b<<endl;
using namespace std;
const int N=2e5+10;
int a[N];
map<int,int>mp;
int main()
{

    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        mp[x]=i;
    }
    int i=0,T=n;
    while(T--)
    {
        int x;
        cin>>x;
        if(mp[x]<i) cout<<0<<' ';
        else
        {
            int y=mp[x]-i+1;
            cout<<y<<' ';
            i=mp[x]+1;
        }
    }
    return 0;
}
/*
1+4+9
*/


#include<bits/stdc++.h>

#define ll long long
#define inf 0x3f3f3f3f
#define debug(a,b) cout<<a<<" "<<b<<endl;
using namespace std;
const int N=2e5+10;
int mp[N];
int main()
{

    int n,x;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        mp[x]=i;
    }
    int i=0;
    for(int j=0;j<n;j++)
    {
        cin>>x;
        if(mp[x]<i) cout<<0<<' ';
        else
        {
            int  y=mp[x]-i+1;
            cout<<y<<' ';
            i=mp[x]+1;
        }
    }
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
#define inf 0x3f3f3f3f
#define debug(a,b) cout<<a<<" "<<b<<endl;
using namespace std;
const int N=2e5+10;
int a[N];
set<int>st;
int main()
{

    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        st.insert(a[i]);
    }
    int i=0,T=n;
    while(T--)
    {
        int x;
        cin>>x;
        if(st.count(x)==0) cout<<0<<' ';
        else
        {

            int j;
            for(j=i;j<n;j++)
            {
                st.erase(a[j]);
                if(a[j]==x)
                {
                    cout<<j-i+1<<' ';
                    break;
                }
            }
            //debug("i=",i);
            i=j+1;

        }
    }
    return 0;
}
/*
1+4+9
*/


#include<bits/stdc++.h>

#define ll long long
#define inf 0x3f3f3f3f
#define debug(a,b) cout<<a<<" "<<b<<endl;
using namespace std;
const int N=2e5+10;
int mp[N];
int main()
{

    int n,x;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&n);
        mp[x]=i;
    }
    int i=0;
    for(int j=0;j<n;j++)
    {
        scanf("%d",&x);
        if(mp[x]<i) printf("%d ",0);
        else
        {
            int  y=mp[x]-i+1;
            printf("%d ",y);
            i=mp[x]+1;
        }
    }
    return 0;
}
/*
1+4+9
*/


#include<bits/stdc++.h>

#define ll long long
#define inf 0x3f3f3f3f
#define debug(a,b) cout<<a<<" "<<b<<endl;
using namespace std;
const int N=2e5+10;
int mp[N];
int main()
{
    ios::sync_with_stdio(0);
    int n,x;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        mp[x]=i;
    }
    int i=0;
    for(int j=0;j<n;j++)
    {
        cin>>x;
        if(mp[x]<i) cout<<0<<' ';
        else
        {
            int  y=mp[x]-i+1;
            cout<<y<<' ';
            i=mp[x]+1;
        }
    }
    return 0;
}
#include<bits/stdc++.h>

#define ll long long
#define inf 0x3f3f3f3f
#define debug(a,b) cout<<a<<" "<<b<<endl;
using namespace std;
const int N=2e5+10;
int mp[N];
int main()
{
    ios::sync_with_stdio(0);
    int n,x;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        mp[x]=i;
    }
    int i=0;
    for(int j=0;j<n;j++)
    {
        cin>>x;
        if(mp[x]<i) cout<<0<<' ';
        else
        {
            int  y=mp[x]-i+1;
            cout<<y<<' ';
            i=mp[x]+1;
        }
    }
    return 0;
}


#include<bits/stdc++.h>

#define ll long long
#define inf 0x3f3f3f3f
#define debug(a,b) cout<<a<<" "<<b<<endl;
using namespace std;
const int N=2e5+10;
int mp[N];
int main()
{

    int n,x;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);
        mp[x]=i;
    }
    int i=0;
    for(int j=0;j<n;j++)
    {
        scanf("%d",&x);
        if(mp[x]<i) printf("%d ",0);
        else
        {
            int  y=mp[x]-i+1;
            printf("%d ",y);
            i=mp[x]+1;
        }
    }
    return 0;
}
/*
1+4+9
*/


///***###                               بسم الله الرحمن الرحيم                            ###***///

/*
                    Author          : Borhan Uddin Rafi
                    University      : Begum Rokeya University,Rangpur.
                    Date            : 19 Oct,2020;
*/

///************************Start Of Template*************************///

#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;
//////graph////////
int arr[200000+4];
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    //Read_Fast;
    int t=1;
    //  cin>>t;
    int cas=0;
    while(t--)
    {
        int n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        int a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>n;

        for(i=1; i<=n; i++)
        {
            cin>>a;
            arr[a]=i;
        }
        cin>>a;
        x=arr[a];
        cout<<x<<" ";
        for(i=1; i<n; i++)
        {
            cin>>a;
            y=arr[a];
            if(y>x)
            {
                ans=y-x;
                x=y;
                cout<<ans<<" ";
            }
            else
            {
                cout<<0<<" ";
            }
        }
        cout<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


///***###                               بسم الله الرحمن الرحيم                            ###***///

/*
                    Author          : Borhan Uddin Rafi
                    University      : Begum Rokeya University,Rangpur.
                    Date            : 19 Oct,2020;
*/

///************************Start Of Template*************************///

#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;
//////graph////////

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    //Read_Fast;
    int t=1;
    //  cin>>t;
    int cas=0;
    while(t--)
    {
        int n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        int a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>n;
        int arr[n+4];
        mem(arr,0);

        for(i=1; i<=n; i++)
        {
            cin>>a;
            arr[a]=i;
        }
        cin>>a;
        x=arr[a];
        cout<<x<<" ";
        for(i=1; i<n; i++)
        {
            cin>>a;
            y=arr[a];
            if(y>x)
            {
                ans=y-x;
                x=y;
                cout<<ans<<" ";
            }
            else
            {
                cout<<0<<" ";
            }
        }
        cout<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


///***###                               بسم الله الرحمن الرحيم                            ###***///

/*
                    Author          : Borhan Uddin Rafi
                    University      : Begum Rokeya University,Rangpur.
                    Date            : 19 Oct,2020;
*/

///************************Start Of Template*************************///

#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;
//////graph////////

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    //Read_Fast;
    int t=1;
    //  cin>>t;
    int cas=0;
    while(t--)
    {
        ll n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        ll a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>n;
        vector<pair<int,int>>vec,vec1;
        map<int,int>mp1;

        for(i=1; i<=n; i++)
        {
            cin>>a;
            mp1[a]=i;
        }
        x=0;
        for(i=1; i<=n; i++)
        {
            cin>>a;
            b=mp1[a];
            if(b>i)
            {
                ans=b-i+1;
                ans-=x;
                x=ans-1;
                cout<<ans<<" ";
            }
            else
            {
                if(b==i)
                {
                    cout<<1<<" ";
                }
                else
                {
                    cout<<0<<" ";
                }

            }
        }
        cout<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


///***###                               بسم الله الرحمن الرحيم                            ###***///

/*
                    Author          : Borhan Uddin Rafi
                    University      : Begum Rokeya University,Rangpur.
                    Date            : 19 Oct,2020;
*/

///************************Start Of Template*************************///

#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;
//////graph////////
int arr[200000+4];
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    //Read_Fast;
    int t=1;
    //  cin>>t;
    int cas=0;
    while(t--)
    {
        int n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        int a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>n;

        for(i=1; i<=n; i++)
        {
            scanf("%d",&a);
            arr[a]=i;
        }
        scanf("%d",&a);
        x=arr[a];
        cout<<x<<" ";
        for(i=1; i<n; i++)
        {
            scanf("%d",&a);
            y=arr[a];
            if(y>x)
            {
                ans=y-x;
                x=y;
                printf("%d ",ans);
            }
            else
            {
                ans=0;
                printf("%d ",ans);
            }
        }
        cout<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


///***###                               بسم الله الرحمن الرحيم                            ###***///

/*
                    Author          : Borhan Uddin Rafi
                    University      : Begum Rokeya University,Rangpur.
                    Date            : 19 Oct,2020;
*/

///************************Start Of Template*************************///

#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;
//////graph////////
int arr[100000+4];
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    //Read_Fast;
    int t=1;
    //  cin>>t;
    int cas=0;
    while(t--)
    {
        int n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        int a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>n;

        for(i=1; i<=n; i++)
        {
            cin>>a;
            arr[a]=i;
        }
        cin>>a;
        x=arr[a];
        cout<<x<<" ";
        for(i=1; i<n; i++)
        {
            cin>>a;
            y=arr[a];
            if(y>x)
            {
                ans=y-x;
                x=y;
                cout<<ans<<" ";
            }
            else
            {
                cout<<0<<" ";
            }
        }
        cout<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


///***###                               بسم الله الرحمن الرحيم                            ###***///

/*
                    Author          : Borhan Uddin Rafi
                    University      : Begum Rokeya University,Rangpur.
                    Date            : 19 Oct,2020;
*/

///************************Start Of Template*************************///

#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;
//////graph////////

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    //Read_Fast;
    int t=1;
    //  cin>>t;
    int cas=0;
    while(t--)
    {
        ll n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        ll a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>n;
        int arr[n+4];
        mem(arr,0);

        for(i=1; i<=n; i++)
        {
            cin>>a;
            arr[a]=i;
        }
        x=0;
        cin>>a;
        x=arr[a];
        cout<<x<<" ";
        for(i=1; i<n; i++)
        {
            cin>>a;
            y=arr[a];
            if(y>x)
            {
                ans=y-x;
                x=y;
                cout<<ans<<" ";
            }
            else
            {
                cout<<0<<" ";
            }
        }
        cout<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


///***###                               بسم الله الرحمن الرحيم                            ###***///

/*
                    Author          : Borhan Uddin Rafi
                    University      : Begum Rokeya University,Rangpur.
                    Date            : 19 Oct,2020;
*/

///************************Start Of Template*************************///

#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;
//////graph////////

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    //Read_Fast;
    int t=1;
    //  cin>>t;
    int cas=0;
    while(t--)
    {
        ll n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        ll a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>n;
        vector<pair<int,int>>vec,vec1;
        map<int,int>mp1;

        for(i=1; i<=n; i++)
        {
            cin>>a;
            mp1[a]=i;
        }
        x=0;
        cin>>a;
        x=mp1[a];
        cout<<x<<" ";
        for(i=1; i<n; i++)
        {
            cin>>a;
            y=mp1[a];
            if(y>x)
            {
                ans=y-x;
                x=y;
                cout<<ans<<" ";
            }
            else
            {
                /*  if()
                  {
                     cout<<1<<" ";
                     x=mp1[a];
                  }
                  else{*/
                cout<<0<<" ";
                // }
            }
        }
        cout<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define lli long long int
#define pb push_back
#define mp make_pair
#define fo(i,n) for(i=0;i<(n);i++)
#define endl "\n"
#define mod 1000000007

// #include <iostream>
// using namespace std;
int main() {
// 	cout<<"GfG!";
    ios_base::sync_with_stdio(0);
	cin.tie(0);
    lli n;
    cin>>n;
    // cout<<countDivisors(n);
    lli a[n],b[n];
    lli i;
    fo(i,n)cin>>a[i];
    fo(i,n)cin>>b[i];

    lli last=-1;
    for(int i=0;i<n;i++){
        lli count=0;
        lli ind=0;
        // if(!c[b[i]]){
        for(int j=last+1;j<n;j++){
            // c[a[j]]=1;
            if(a[j]==b[i]){ind=j;break;}
        }
        // }
        if(ind<last)cout<<"0 ";
        else{ cout<<ind-last<<" ";last=ind;}
        int p;
        // cout<<endl;
        // fo(p,n)cout<<c[p]<<" ";
        // else cout<<"0 ";

    }
    // fo(i,n)cout<<c[i]<<" ";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define lli long long int
#define pb push_back
#define mp make_pair
#define fo(i,n) for(i=0;i<(n);i++)
#define endl "\n"
#define mod 1000000007

// #include <iostream>
// using namespace std;
int main() {
//      cout<<"GfG!";
    ios_base::sync_with_stdio(0);
        cin.tie(0);
    lli n;
    cin>>n;
    // cout<<countDivisors(n);
    lli a[n],b[n];
    lli i;
    fo(i,n)cin>>a[i];
    fo(i,n)cin>>b[i];
    lli last=-1;
    for(int i=0;i<n;i++){
        lli count=0;
        lli ind=0;
        for(int j=0;j<n;j++){
            if(a[j]==b[i]){ind=j;break;}
        }
        if(ind<last)cout<<"0 ";
        else{ cout<<ind-last<<" ";last=ind;}
        // else cout<<"0 ";

    }
        return 0;
}
~


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define lli long long int
#define pb push_back
#define mp make_pair
#define fo(i,n) for(i=0;i<(n);i++)
#define endl "\n"
#define mod 1000000007

// #include <iostream>
// using namespace std;
int main() {
//      cout<<"GfG!";
    ios_base::sync_with_stdio(0);
        cin.tie(0);
    lli n;
    cin>>n;
    // cout<<countDivisors(n);
    lli a[n],b[n],c[n]={0};
    lli i;
    fo(i,n)cin>>a[i];
    fo(i,n)cin>>b[i];

    lli last=-1;
    for(int i=0;i<n;i++){
        lli count=0;
        lli ind=0;
        if(!c[b[i]]){
        for(int j=0;j<n;j++){
            c[a[j]]=1;
            if(a[j]==b[i]){ind=j;break;}
        }
        }
        if(ind<last)cout<<"0 ";
        else{ cout<<ind-last<<" ";last=ind;}
        // else cout<<"0 ";

    }
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define lli long long int
#define pb push_back
#define mp make_pair
#define fo(i,n) for(i=0;i<(n);i++)
#define endl "\n"
#define mod 1000000007

// #include <iostream>
// using namespace std;
int main() {
// 	cout<<"GfG!";
    ios_base::sync_with_stdio(0);
	cin.tie(0);
    lli n;
    cin>>n;
    // cout<<countDivisors(n);
    lli a[n],b[n];
    lli c[n+1]={0};
    lli i;
    fo(i,n)cin>>a[i];
    fo(i,n)cin>>b[i];
    fo(i,n)c[i]=0;
    lli last=-1;
    for(int i=0;i<n;i++){
        lli count=0;
        lli ind=0;
        if(!c[b[i]]){
        for(int j=last+1;j<n;j++){
            c[a[j]]=1;
            if(a[j]==b[i]){ind=j;break;}
        }
        cout<<ind-last<<" ";
        last=ind;
        }
        else
        cout<<"0 ";
        // else{ }
        // int p;
        // cout<<endl;
        // fo(p,n)cout<<c[p]<<" ";
        // else cout<<"0 ";

    }
    // fo(i,n)cout<<c[i]<<" ";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define lli long long int
#define pb push_back
#define mp make_pair
#define fo(i,n) for(i=0;i<(n);i++)
#define endl "\n"
#define mod 1000000007

// #include <iostream>
// using namespace std;
int main() {
//      cout<<"GfG!";
    ios_base::sync_with_stdio(0);
        cin.tie(0);
    lli n;
    cin>>n;
    // cout<<countDivisors(n);
    lli a[n],b[n];
    lli i;
    fo(i,n)cin>>a[i];
    fo(i,n)cin>>b[i];
    lli last=-1;
    for(int i=0;i<n;i++){
        lli count=0;
        lli ind=0;
        for(int j=0;j<n;j++){
            if(a[j]==b[i]){ind=j;break;}
        }
        if(ind<last)cout<<"0 ";
        else{ cout<<ind-last<<" ";last=ind;}
        // else cout<<"0 ";

    }
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define lli long long int
#define pb push_back
#define mp make_pair
#define fo(i,n) for(i=0;i<(n);i++)
#define endl "\n"
#define mod 1000000007

// #include <iostream>
// using namespace std;
int main() {
//      cout<<"GfG!";
    ios_base::sync_with_stdio(0);
        cin.tie(0);
    lli n;
    cin>>n;
    // cout<<countDivisors(n);
    lli a[n],b[n],c[n]={0};
    lli i;
    fo(i,n)cin>>a[i];
    fo(i,n)cin>>b[i];

    lli last=-1;
    for(int i=0;i<n;i++){
        lli count=0;
        lli ind=0;
        if(!c[b]){
        for(int j=0;j<n;j++){
            c[a[j]]=1;
            if(a[j]==b[i]){ind=j;break;}
        }
        }
        if(ind<last)cout<<"0 ";
        else{ cout<<ind-last<<" ";last=ind;}
        // else cout<<"0 ";

    }
        return 0;
}


//*
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
int inversedArray[200005], numBooks;
int main()
{
	scanf("%d", &numBooks);
	for (int i = 1; i <= numBooks; i++)
	{
		int bookNum;
		scanf("%d", &bookNum);
		inversedArray[bookNum] = i;
	}
	int ml = 0;
	for (int i = 1; i <= numBooks; i++)
	{
		int bookNum;
		scanf("%d", &bookNum);
		printf("%d ", (0 >= (inversedArray[bookNum] - ml) ? 0 : (inversedArray[bookNum] - ml))); //if current index of book (i=inv[bookNum]) is less than the previous max index, print 0, otherwise print, currentIndexOfGivenBook-numPreviousMaxTaken
		ml = (ml >= inversedArray[bookNum] ? ml : inversedArray[bookNum]); //if current index is greater than max, change max, otherwise do nothing
	}
}
//*/

/*
#include <iostream>
using namespace std;
int inversedArray[200005], numBooks;
int main()
{
	cin >> numBooks;
	for (int i = 1; i <= numBooks; i++)
	{
		int bookNum;
		cin >> bookNum;
		inversedArray[bookNum] = i;
	}
	int ml = 0;
	for (int i = 1; i <= numBooks; i++)
	{
		int bookNum;
		cin >> bookNum;
		cout << (0 >= (inversedArray[bookNum] - ml) ? 0 : (inversedArray[bookNum] - ml)) << " "; //if current index of book (i=inv[bookNum]) is less than the previous max index, print 0, otherwise print, currentIndexOfGivenBook-numPreviousMaxTaken
		ml = (ml >= inversedArray[bookNum] ? ml : inversedArray[bookNum]); //if current index is greater than max, change max, otherwise do nothing
	}
}
*/


#include <iostream>
#include <cstring>
#include <string>
using namespace std;

int main()
{
	int num;
	std::cin >> num;
	int* stack = new int[num];
	int* hash = new int[num];
//	int* steps = new int[num];

	for (int i = 0; i < num; ++i)
	{
		std::cin >> stack[i];
		hash[--stack[i]] = i;
	}
	int oldMax = -1;
	int remIndex;
	int step;

	char out[1000000]="";
//	char space[10] = " ";
	char numBuff[10] = "";
	for (int i = 0; i < num; ++i)
	{
		std::cin >> step;
		remIndex = hash[step-1];

		if (remIndex <= oldMax)
		{
			//if (num != 200000)
				strcat(out, "0 ");
//				cout << 0 << " ";
		}
		else
		{
			strcat(out, " ");

			strcat(out, to_string(remIndex - oldMax).~basic_string);
//			space[0] = ' ';
//			space[1] = '\0';
//			numBuff[0] = '\0';
//			cout << (remIndex - oldMax) << " ";
			oldMax = remIndex;
		}
	}
	cout << out;
//	system("pause");
}


#include <iostream>
using namespace std;

int main()
{
	int num;
	cin >> num;
	int* stack = new int[num];
	int* hash = new int[num];
//	int* steps = new int[num];

	for (int i = 0; i < num; ++i)
	{
		cin >> stack[i];
		hash[--stack[i]] = i;
	}
	int oldMax = -1;
	int remIndex;
	int step;
	for (int i = 0; i < num; ++i)
	{
		cin >> step;
		remIndex = hash[step-1];

		if (remIndex <= oldMax)
		{
			//if(num!= 200000)
			cout << 0 << " ";
		}
		else
		{
			cout << (remIndex - oldMax) << " ";
			oldMax = remIndex;
		}
	}
	cout << endl;
//	system("pause");
}


/*#include <iostream>
using namespace std;
int inversedArray[200005], numBooks;
int main()
{
	scanf("%d", &numBooks);
	for (int i = 1; i <= numBooks; i++)
	{
		int bookNum;
		scanf("%d", &bookNum);
		inversedArray[bookNum] = i;
	}
	int ml = 0;
	for (int i = 1; i <= numBooks; i++)
	{
		int bookNum;
		scanf("%d", &bookNum);
		printf("%d ", (0 >= (inversedArray[bookNum] - ml) ? 0 : (inversedArray[bookNum] - ml))); //if current index of book (i=inv[bookNum]) is less than the previous max index, print 0, otherwise print, currentIndexOfGivenBook-numPreviousMaxTaken
		ml = (ml >= inversedArray[bookNum] ? ml : inversedArray[bookNum]); //if current index is greater than max, change max, otherwise do nothing
	}
}*/

#include <iostream>
using namespace std;
int inversedArray[200005], numBooks;
int main()
{
	cin >> numBooks;
	for (int i = 1; i <= numBooks; i++)
	{
		int bookNum;
		cin >> bookNum;
		inversedArray[bookNum] = i;
	}
	int ml = 0;
	for (int i = 1; i <= numBooks; i++)
	{
		int bookNum;
		cin >> bookNum;
		cout << (0 >= (inversedArray[bookNum] - ml) ? 0 : (inversedArray[bookNum] - ml)) << " "; //if current index of book (i=inv[bookNum]) is less than the previous max index, print 0, otherwise print, currentIndexOfGivenBook-numPreviousMaxTaken
		ml = (ml >= inversedArray[bookNum] ? ml : inversedArray[bookNum]); //if current index is greater than max, change max, otherwise do nothing
	}
}


/*#include <iostream>
using namespace std;
int inversedArray[200005], numBooks;
int main()
{
	scanf("%d", &numBooks);
	for (int i = 1; i <= numBooks; i++)
	{
		int bookNum;
		scanf("%d", &bookNum);
		inversedArray[bookNum] = i;
	}
	int ml = 0;
	for (int i = 1; i <= numBooks; i++)
	{
		int bookNum;
		scanf("%d", &bookNum);
		printf("%d ", (0 >= (inversedArray[bookNum] - ml) ? 0 : (inversedArray[bookNum] - ml))); //if current index of book (i=inv[bookNum]) is less than the previous max index, print 0, otherwise print, currentIndexOfGivenBook-numPreviousMaxTaken
		ml = (ml >= inversedArray[bookNum] ? ml : inversedArray[bookNum]); //if current index is greater than max, change max, otherwise do nothing
	}
}*/

#include <iostream>
using namespace std;
int inversedArray[200005], numBooks;
int main()
{
	cin >> numBooks;
	for (int i = 1; i <= numBooks; i++)
	{
		int bookNum;
		cin >> bookNum;
		inversedArray[bookNum] = i;
	}
	int ml = 0;
	for (int i = 1; i <= numBooks; i++)
	{
		int bookNum;
		cin >> bookNum;
		cout << (0 >= (inversedArray[bookNum] - ml) ? 0 : (inversedArray[bookNum] - ml)); //if current index of book (i=inv[bookNum]) is less than the previous max index, print 0, otherwise print, currentIndexOfGivenBook-numPreviousMaxTaken
		ml = (ml >= inversedArray[bookNum] ? ml : inversedArray[bookNum]); //if current index is greater than max, change max, otherwise do nothing
	}
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;

int inverseStack[200001];
int main()
{
	int num;
	cin >> num;

	int val;
	for (int i = 0; i < num; ++i)
	{
		scanf("%d", &val);
		inverseStack[val-1] = i;
	}

	int oldMax = -1;
	int remIndex;
	int step;
	for (int i = 0; i < num; ++i)
	{
		scanf("%d", &step);
		remIndex = inverseStack[step - 1];

		if (remIndex > oldMax)
		{
			printf("%d ", (remIndex - oldMax));
			oldMax = remIndex;
		}
		else
		{
			printf("0 ");
		}
	}
}


#include <iostream>
using namespace std;

int main()
{
	int num;
	cin >> num;
	int* stack = new int[num];
	int* hash = new int[num];
//	int* steps = new int[num];

	for (int i = 0; i < num; ++i)
	{
		cin >> stack[i];
		hash[--stack[i]] = i;
	}
	int oldMax = -1;
	int remIndex;
	for (int i = 0; i < num; ++i)
	{
		int step;
		cin >> step;
		remIndex = hash[step-1];

		if (remIndex > oldMax)
		{
			if(oldMax==-1)
				cout << (remIndex+1) << " ";
			else
				cout << (remIndex - oldMax) << " ";
			oldMax = remIndex;
		}
		else
		{
			cout << 0 << " ";
		}
	}
	cout << endl;
//	system("pause");
}


#include <iostream>
using namespace std;

int main()
{
	int num;
	cin >> num;
	int* stack = new int[num];
	int* hash = new int[num];
//	int* steps = new int[num];

	for (int i = 0; i < num; ++i)
	{
		cin >> stack[i];
		hash[--stack[i]] = i;
	}
	int oldMax = -1;
	int remIndex;
	int step;
	for (int i = 0; i < num; ++i)
	{
		cin >> step;
		remIndex = hash[step-1];

		if (remIndex > oldMax)
		{
			cout << (remIndex - oldMax) << " ";
			oldMax = remIndex;
		}
		else
		{
			//if(num!= 200000)
				cout << 0 << " ";
		}
	}
	cout << endl;
//	system("pause");
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CF Vasya and Books", "CF Vasya and Books\CF Vasya and Books.vcxproj", "{90EC06BB-B4A7-4CDF-A1DE-C9E8257CE794}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|x64 = Debug|x64
		Debug|x86 = Debug|x86
		Release|x64 = Release|x64
		Release|x86 = Release|x86
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{90EC06BB-B4A7-4CDF-A1DE-C9E8257CE794}.Debug|x64.ActiveCfg = Debug|x64
		{90EC06BB-B4A7-4CDF-A1DE-C9E8257CE794}.Debug|x64.Build.0 = Debug|x64
		{90EC06BB-B4A7-4CDF-A1DE-C9E8257CE794}.Debug|x86.ActiveCfg = Debug|Win32
		{90EC06BB-B4A7-4CDF-A1DE-C9E8257CE794}.Debug|x86.Build.0 = Debug|Win32
		{90EC06BB-B4A7-4CDF-A1DE-C9E8257CE794}.Release|x64.ActiveCfg = Release|x64
		{90EC06BB-B4A7-4CDF-A1DE-C9E8257CE794}.Release|x64.Build.0 = Release|x64
		{90EC06BB-B4A7-4CDF-A1DE-C9E8257CE794}.Release|x86.ActiveCfg = Release|Win32
		{90EC06BB-B4A7-4CDF-A1DE-C9E8257CE794}.Release|x86.Build.0 = Release|Win32
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {E56611DC-DF05-427E-8243-2393D9DC9955}
	EndGlobalSection
EndGlobal


#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	int num;
	std::cin >> num;
	int* stack = new int[num];
	int* hash = new int[num];
//	int* steps = new int[num];

	for (int i = 0; i < num; ++i)
	{
		std::cin >> stack[i];
		hash[--stack[i]] = i;
	}
	int oldMax = -1;
	int remIndex;
	int step;

	char out[1000000]="";
	char space[10] = " ";
	for (int i = 0; i < num; ++i)
	{
		std::cin >> step;
		remIndex = hash[step-1];

		if (remIndex <= oldMax)
		{
			//if (num != 200000)
				strcat(out, "0 ");
//				cout << 0 << " ";
		}
		else
		{

			strcat(out, itoa((remIndex - oldMax), space, 10));
			space[0] = ' ';
			space[1] = '\0';
//			cout << (remIndex - oldMax) << " ";
			oldMax = remIndex;
		}
	}
	cout << out;
//	system("pause");
}


#include <iostream>
using namespace std;

int main()
{
	int num;
	std::cin >> num;
	int* stack = new int[num];
	int* hash = new int[num];
//	int* steps = new int[num];

	for (int i = 0; i < num; ++i)
	{
		std::cin >> stack[i];
		hash[--stack[i]] = i;
	}
	int oldMax = -1;
	int remIndex;
	int step;

	char out[1000000]="";
	char space[10] = " ";
	for (int i = 0; i < num; ++i)
	{
		std::cin >> step;
		remIndex = hash[step-1];

		if (remIndex <= oldMax)
		{
			//if (num != 200000)
				strcat(out, "0 ");
//				cout << 0 << " ";
		}
		else
		{

			strcat(out, itoa((remIndex - oldMax), space, 10));
			space[0] = ' ';
			space[1] = '\0';
//			cout << (remIndex - oldMax) << " ";
			oldMax = remIndex;
		}
	}
	cout << out;
//	system("pause");
}


#include <iostream>
#include <cstring>
#include <string>
using namespace std;

int main()
{
	int num;
	std::cin >> num;
	int* stack = new int[num];
	int* hash = new int[num];
//	int* steps = new int[num];

	for (int i = 0; i < num; ++i)
	{
		std::cin >> stack[i];
		hash[--stack[i]] = i;
	}
	int oldMax = -1;
	int remIndex;
	int step;

	char out[1000000]="";
//	char space[10] = " ";
	char numBuff[10] = "";
	for (int i = 0; i < num; ++i)
	{
		std::cin >> step;
		remIndex = hash[step-1];

		if (remIndex <= oldMax)
		{
			//if (num != 200000)
				strcat(out, "0 ");
//				cout << 0 << " ";
		}
		else
		{
			strcat(out, itoa((remIndex - oldMax),numBuff,10));
			strcat(out, " ");
//			space[0] = ' ';
//			space[1] = '\0';
//			numBuff[0] = '\0';
//			cout << (remIndex - oldMax) << " ";
			oldMax = remIndex;
		}
	}
	cout << out;
//	system("pause");
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define inf 1e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string str;
		cin>>str;
		int minimum=INT_MAX,c=0;
		for(int i=0;i<str.size();i++)
		{
			if(str[i]=='+')c++;
			else c--;
			if(c<minimum) minimum=c;
		}
		c=0;
		int a=-1*minimum,b=0;
		ll res=0;
		int i=0;
		//cout<<a<<endl;
		for(i=0;i<str.size();i++)
		{
			if(str[i]=='+')c++;
			else c--;

			if(b+c<0)
			{
				res+=(i+1);
				b++;
			}
			if(b>a)break;
		}
		if((i==str.size())||(res==0)) res+=str.size();
		cout<<res<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define inf 1e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

int main()
{
    fast
	int t;
	cin>>t;
	while(t--)
	{
		string str;
		cin>>str;

		ll res=0,curr;
		bool ok=false;
		int a=0;
		while(1)
		{
			curr=a;
			ok=true;

			for(int i=0;i<str.size();i++)
			{
				res++;
				if(str[i]=='+')curr++;
				else curr--;

				if(curr<0)
				{
					ok=false;
					break;
				}
			}
			a++;
			if(ok==true) break;
		}

		cout<<res<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define inf 1e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

/*
res = 0
for init = 0 to inf
    cur = init
    ok = true
    for i = 1 to |s|
        res = res + 1
        if s[i] == '+'
            cur = cur + 1
        else
            cur = cur - 1
        if cur < 0
            ok = false
            break
    if ok
        break
*/
/*
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string str;
		cin>>str;

		ll res=0,curr;
		bool ok=false;
		int a=0;
		while(1)
		{
			curr=a;
			ok=true;

			for(int i=0;i<str.size();i++)
			{
				res++;
				if(str[i]=='+')curr++;
				else curr--;

				if(curr<0)
				{
					ok=false;
					break;
				}
			}
			a++;
			if(ok==true) break;
		}

		cout<<res<<endl;
	}
}*/

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string str;
		cin>>str;
		int minimum=INT_MAX,c=0;
		for(int i=0;i<str.size();i++)
		{
			if(str[i]=='+')c++;
			else c--;
			if(c<minimum) minimum=c;
		}
		c=0;
		int a=-1*minimum,b=0;
		int res=0;
		int i=0;
		//cout<<a<<endl;
		for(i=0;i<str.size();i++)
		{
			if(str[i]=='+')c++;
			else c--;

			if(b+c<0)
			{
				res+=(i+1);
				b++;
			}
			if(b>a)break;
		}
		if(i==str.size()&&b<=a) res+=str.size();
		cout<<res<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define inf 1e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

/*
res = 0
for init = 0 to inf
    cur = init
    ok = true
    for i = 1 to |s|
        res = res + 1
        if s[i] == '+'
            cur = cur + 1
        else
            cur = cur - 1
        if cur < 0
            ok = false
            break
    if ok
        break
*/
/*
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string str;
		cin>>str;

		ll res=0,curr;
		bool ok=false;
		int a=0;
		while(1)
		{
			curr=a;
			ok=true;

			for(int i=0;i<str.size();i++)
			{
				res++;
				if(str[i]=='+')curr++;
				else curr--;

				if(curr<0)
				{
					ok=false;
					break;
				}
			}
			a++;
			if(ok==true) break;
		}

		cout<<res<<endl;
	}
}*/

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string str;
		cin>>str;
		int minimum=INT_MAX,c=0;
		for(int i=0;i<str.size();i++)
		{
			if(str[i]=='+')c++;
			else c--;
			if(c<minimum) minimum=c;
		}
		c=0;
		int a=-1*minimum,b=0;
		int res=0;
		int i=0;
		//cout<<a<<endl;
		for(i=0;i<str.size();i++)
		{
			if(str[i]=='+')c++;
			else c--;

			if(b+c<0)
			{
				res+=(i+1);
				b++;
			}
			if(b>a)break;
		}
		if(i!=str.size()-1) res+=str.size();
		cout<<res<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define inf 1e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

/*
res = 0
for init = 0 to inf
    cur = init
    ok = true
    for i = 1 to |s|
        res = res + 1
        if s[i] == '+'
            cur = cur + 1
        else
            cur = cur - 1
        if cur < 0
            ok = false
            break
    if ok
        break
*/
/*
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string str;
		cin>>str;

		ll res=0,curr;
		bool ok=false;
		int a=0;
		while(1)
		{
			curr=a;
			ok=true;

			for(int i=0;i<str.size();i++)
			{
				res++;
				if(str[i]=='+')curr++;
				else curr--;

				if(curr<0)
				{
					ok=false;
					break;
				}
			}
			a++;
			if(ok==true) break;
		}

		cout<<res<<endl;
	}
}
*/
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string str;
		cin>>str;
		int minimum=INT_MAX,c=0;
		for(int i=0;i<str.size();i++)
		{
			if(str[i]=='+')c++;
			else c--;
			if(c<minimum) minimum=c;
		}
		c=0;
		int a=-1*minimum,b=0;
		int res=0;
		int i=0;
		//cout<<a<<endl;
		for(i=0;i<str.size();i++)
		{
			if(str[i]=='+')c++;
			else c--;

			if(b+c<0)
			{
				res+=(i+1);
				b++;
			}
			if(b>a)break;
		}
		if((i==str.size()&&b<=a)||(res==0)) res+=str.size();
		cout<<res<<endl;
	}
}


int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string str;
		cin>>str;

		ll res=0,curr;
		bool ok=false;
		int a=0;
		while(1)
		{
			curr=a;
			ok=true;

			for(int i=0;i<str.size();i++)
			{
				res++;
				if(str[i]=='+')curr++;
				else curr--;

				if(curr<0)
				{
					ok=false;
					break;
				}
			}
			a++;
			if(ok==true) break;
		}

		cout<<res<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;
const long long MOD=1000000007;
const long long N=100000;

long long bf(long long l,long long r)
{
    long long res=0;
    for(long long i=l; i<=r; i++)
    {
        long long temp = __builtin_popcount(i);
        res=max(res,temp);
    }
    for(long long i=l; i<=r; i++)
    {
        long long temp = __builtin_popcount(i);
        if(temp==res)
        {
            return i;
        }
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long t;
    cin>>t;
    while(t--)
    {
        string a;
        cin >> a;
        long long bal=0;
        map<long long,long long> freq;
        for(long long i=0; i<a.length(); i++)
        {
            if(a[i]=='+')
                bal++;
            else
                bal--;
            if(bal<0 )
            {
                if(freq.find(bal)==freq.end())
                    freq[bal]=i+1;
            }
        }
        long long res=a.length();
        for(auto x:freq) res+=x.second;
        cout<<res<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
long long pct(long long x) { return __builtin_popcount(x); }
long long bits(long long x) { return 31-__builtin_clz(x); }
long long cdiv(long long a, long long b) { return a/b+!(a<0||a%b == 0); }
long long fstTrue(function<bool(long long)> f, long long lo, long long hi) {
 hi ++; assert(lo <= hi);
 while (lo < hi) {
  long long mid = (lo+hi)/2;
  f(mid) ? hi = mid : lo = mid+1;
 }
 return lo;
}
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
 unsyncIO();

 if (s.size()) { setIn(s+".in"), setOut(s+".out"); }
}
typedef int32_t start;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long bf(string a){
 long long res=0;
 long long cnt=0;
 for(long long i=0;i<100;i++){
  long long cur=i;
  bool ok=1;
  for(long long j=0;j<a.length();j++){
   res++;
   if(a[j]== '+'){
    cur++;
   }else{
    cur--;
   }
   if(cur<0){
    ok=false;
    break;
   }
  }

  if(ok)break;
 }
 return res;
}

long long fast(string a){
 long long bal=0;
 long long mini=0;
 long long meat=1;
 bool notfound=1;
 map<long long,long long> temp;
 for(long long i=0;i<a.length();i++){
  if(a[i]=='+')bal++;
  else bal--;
  if(bal<0 and temp.find(bal)==temp.end()){
   temp[bal]=i+1;
  }
 }
 long long res=a.length();
 for(auto x:temp){

  res+=x.second;
 }

 return res;
}

string gen(long long n){
 string res="";
 for(long long i=0;i<n;i++){
  res.push_back(rand()%2==0?'+':'-');
 }
 return res;
}
start main(){
 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 srand(time(NULL));
 long long t;
 cin >> t;
 while(t--){
  string a;
  cin >> a;
  cout<<fast(a)<<'\n';
 }
 return 0;
}


#include <bits/stdc++.h>

using namespace std;
long long pct(long long x) { return __builtin_popcount(x); }
long long bits(long long x) { return 31-__builtin_clz(x); }
long long cdiv(long long a, long long b) { return a/b+!(a<0||a%b == 0); }
long long fstTrue(function<bool(long long)> f, long long lo, long long hi) {
 hi ++; assert(lo <= hi);
 while (lo < hi) {
  long long mid = (lo+hi)/2;
  f(mid) ? hi = mid : lo = mid+1;
 }
 return lo;
}
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
 unsyncIO();

 if (s.size()) { setIn(s+".in"), setOut(s+".out"); }
}
typedef int32_t start;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long bf(string a){
 long long res=0;
 long long cnt=0;
 for(long long i=0;i<1000;i++){
  long long cur=i;
  bool ok=1;
  for(long long j=0;j<a.length();j++){
   res++;
   if(a[j]== '+'){
    cur++;
   }else{
    cur--;
   }
   if(cur<0){
    ok=false;
    break;
   }
  }

  if(ok)break;
 }
 return res;
}

long long fast(string a){
 long long bal=0;
 long long mini=0;
 long long meat=1;
 bool notfound=1;
 map<long long,long long> temp;
 for(long long i=0;i<a.length();i++){
  if(a[i]=='+')bal++;
  else bal--;
  if(bal<0 and temp.find(bal)==temp.end()){
   temp[bal]=i+1;
  }
 }
 long long res=a.length();
 for(auto x:temp){

  res+=x.second;
 }

 return res;
}

string gen(long long n){
 string res="";
 for(long long i=0;i<n;i++){
  res.push_back(rand()%2==0?'+':'-');
 }
 return res;
}
start main(){
 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 srand(time(NULL));
 long long t;
 cin >> t;
 while(t--){
  string a;
  cin >> a;
  cout<<fast(a)<<'\n';
 }
 return 0;
}


#include <bits/stdc++.h>

using namespace std;
const long long MOD=1000000007;
const long long N=100000;

unsigned hash_f(unsigned x)
{
    x = ((x >> 16) ^ x) * 0x45d9f3b;
    x = ((x >> 16) ^ x) * 0x45d9f3b;
    x = (x >> 16) ^ x;
    return x;
}

struct chash
{
    const long long RANDOM = (long long)(make_unique<char>().get()) ^ chrono::high_resolution_clock::now().time_since_epoch().count();
    static unsigned long long hash_f(unsigned long long x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    static unsigned hash_combine(unsigned a, unsigned b)
    {
        return a * 31 + b;
    }
    long long operator()(long long x) const
    {
        return hash_f(x)^RANDOM;
    }
};

struct pairhash
{
    long long operator()(pair<long long,long long> x) const
    {
        return hash_f(x.first) * 31 + hash_f(x.second);
    }
};

long long bf(long long l,long long r)
{
    long long res=0;
    for(long long i=l; i<=r; i++)
    {
        long long temp = __builtin_popcount(i);
        res=max(res,temp);
    }
    for(long long i=l; i<=r; i++)
    {
        long long temp = __builtin_popcount(i);
        if(temp==res)
        {
            return i;
        }
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long t;
    cin>>t;
    while(t--)
    {
        string a;
        cin >> a;
        long long bal=0;
        map<long long,long long> freq;
        for(long long i=0; i<a.length(); i++)
        {
            if(a[i]=='+')
                bal++;
            else
                bal--;
            if(bal<0 )
            {
                if(freq.find(bal)==freq.end())
                    freq[bal]=i+1;
            }
        }
        long long res=a.length();
        for(auto x:freq) res+=x.second;
        cout<<res<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
long long mxm() {return LLONG_MIN;}
template<typename... Args>
long long mxm(long long a, Args... args) { return max(a,mxm(args...)); }

long long mnm() {return LLONG_MAX;}
template<typename... Args>
long long mnm(long long a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
 os<<"[ ";for(auto v:V)os<<v<<", ";return os<<"]";
}
template<class T> ostream& operator<<(ostream& os,set<T> V){
 os<<"[ ";for(auto v:V)os<<v<<", ";return os<<"]";
}
template<class T> ostream& operator<<(ostream& os,multiset<T> V){
 os<<"[ ";for(auto v:V)os<<v<<", ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
 return os<<"("<<P.first<<","<<P.second<<")";
}
long long pct(long long x) { return __builtin_popcount(x); }
long long bits(long long x) { return 31-__builtin_clz(x); }
long long cdiv(long long a, long long b) { return a/b+!(a<0||a%b == 0); }
long long fstTrue(function<bool(long long)> f, long long lo, long long hi) {
 hi ++; assert(lo <= hi);
 while (lo < hi) {
  long long mid = (lo+hi)/2;
  f(mid) ? hi = mid : lo = mid+1;
 }
 return lo;
}
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
 unsyncIO();

 if (s.size()) { setIn(s+".in"), setOut(s+".out"); }
}
typedef int32_t start;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long bf(string a){
 long long res=0;
 long long cnt=0;
 for(long long i=0;i<1000;i++){
  long long cur=i;
  bool ok=1;
  for(long long j=0;j<a.length();j++){
   res++;
   if(a[j]== '+'){
    cur++;
   }else{
    cur--;
   }
   if(cur<0){
    ok=false;
    break;
   }
  }

  if(ok)break;
 }
 return res;
}

long long fast(string a){
 long long bal=0;
 long long mini=0;
 long long meat=1;
 bool notfound=1;
 map<long long,long long> temp;
 for(long long i=0;i<a.length();i++){
  if(a[i]=='+')bal++;
  else bal--;
  if(bal<0 and temp.find(bal)==temp.end()){
   temp[bal]=i+1;
  }
 }
 long long res=a.length();
 for(auto x:temp){

  res+=x.second;
 }

 return res;
}

string gen(long long n){
 string res="";
 for(long long i=0;i<n;i++){
  res.push_back(rand()%2==0?'+':'-');
 }
 return res;
}
start main(){
 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 srand(time(NULL));
 long long t;
 cin >> t;
 while(t--){
  string a;
  cin >> a;
  cout<<fast(a)<<'\n';
 }

        if(1){
            for(long long kk=0;kk<=1000;kk++){
                long long pp=34;
                long long up=20;
                long long cp=13*23;
                pp=up+cp;
                pp=up+cp;
                pp=up+cp;
            }
        }
 return 0;
}


#include <bits/stdc++.h>

using namespace std;
long long mxm() {return LLONG_MIN;}
template<typename... Args>
long long mxm(long long a, Args... args) { return max(a,mxm(args...)); }

long long mnm() {return LLONG_MAX;}
template<typename... Args>
long long mnm(long long a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
 os<<"[ ";for(auto v:V)os<<v<<", ";return os<<"]";
}
template<class T> ostream& operator<<(ostream& os,set<T> V){
 os<<"[ ";for(auto v:V)os<<v<<", ";return os<<"]";
}
template<class T> ostream& operator<<(ostream& os,multiset<T> V){
 os<<"[ ";for(auto v:V)os<<v<<", ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
 return os<<"("<<P.first<<","<<P.second<<")";
}
long long pct(long long x) { return __builtin_popcount(x); }
long long bits(long long x) { return 31-__builtin_clz(x); }
long long cdiv(long long a, long long b) { return a/b+!(a<0||a%b == 0); }
long long fstTrue(function<bool(long long)> f, long long lo, long long hi) {
 hi ++; assert(lo <= hi);
 while (lo < hi) {
  long long mid = (lo+hi)/2;
  f(mid) ? hi = mid : lo = mid+1;
 }
 return lo;
}
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
 unsyncIO();

 if (s.size()) { setIn(s+".in"), setOut(s+".out"); }
}
typedef int32_t start;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long bf(string a){
 long long res=0;
 long long cnt=0;
 for(long long i=0;i<1000;i++){
  long long cur=i;
  bool ok=1;
  for(long long j=0;j<a.length();j++){
   res++;
   if(a[j]== '+'){
    cur++;
   }else{
    cur--;
   }
   if(cur<0){
    ok=false;
    break;
   }
  }

  if(ok)break;
 }
 return res;
}

long long fast(string a){
 long long bal=0;
 long long mini=0;
 long long meat=1;
 bool notfound=1;
 map<long long,long long> temp;
 for(long long i=0;i<a.length();i++){
  if(a[i]=='+')bal++;
  else bal--;
  if(bal<0 and temp.find(bal)==temp.end()){
   temp[bal]=i+1;
  }
 }
 long long res=a.length();
 for(auto x:temp){

  res+=x.second;
 }

 return res;
}

string gen(long long n){
 string res="";
 for(long long i=0;i<n;i++){
  res.push_back(rand()%2==0?'+':'-');
 }
 return res;
}
start main(){
 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 srand(time(NULL));
 long long t;
 cin >> t;
 while(t--){
  string a;
  cin >> a;
  cout<<fast(a)<<'\n';
 }

        if(1){
            for(long long kk=0;kk<=1000;kk++){
                long long pp=34;
                long long up=20;
                long long cp=13*23;
                pp=up+cp;
                pp=up+cp;
                pp=up+cp;
            }
        }

        if(1){
            for(long long kk=0;kk<=1000;kk++){
                long long pp=34;
                long long up=20;
                long long cp=13*23;
                pp=up+cp;
                pp=up+cp;
                pp=up+cp;
            }
        }
 return 0;
}


// Problem : C. Pluses and Minuses
// Contest : Codeforces - Educational Codeforces Round 90 (Rated for Div. 2)
// URL : https://codeforces.com/contest/1373/problem/C
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//replace_junk
#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <cmath>
#include <ctime>
#include <numeric>
#include <bits/stdc++.h>
//replace_junk
using namespace std;
#define int						long long
#define	pii						pair<int,int>
#define	vpii					vector<pii>
#define	vi						vector<int>
#define	pb						push_back
#define bg						begin()
#define ed						end()
#define ln						length()
#define S						second
#define sz						size()
#define nl						cout<<'\n';
#define all(x)					x.begin(),x.end()
#define endl 					'\n'
#define F						first
#define rep0(n)					for(int i=0;i<n;i++)
#define rep0j(n)				for(int j=0;j<n;j++)
#define QQ						<<" "<<
#define oo(x)					cout<<x<<endl;
#define take(a,n) 				vi a(n);rep0(n){cin>>a[i];}
#define dbl_io(x)				cout<< fixed << setprecision(x)
#define IOS						ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int mxm() {return LLONG_MIN;}
template<typename... Args>
int mxm(int a, Args... args) { return max(a,mxm(args...)); }

int mnm() {return LLONG_MAX;}
template<typename... Args>
int mnm(int a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<", ";return os<<"]";
}
template<class T> ostream& operator<<(ostream& os,set<T> V){
	os<<"[ ";for(auto v:V)os<<v<<", ";return os<<"]";
}
template<class T> ostream& operator<<(ostream& os,multiset<T> V){
	os<<"[ ";for(auto v:V)os<<v<<", ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}
int pct(int x) { return __builtin_popcount(x); }
int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))
int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0
int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true
		int mid = (lo+hi)/2;
		f(mid) ? hi = mid : lo = mid+1;
	}
	return lo;
}
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	// cin.exceptions(cin.failbit);
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (s.sz) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}
typedef int32_t start;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int bf(string a){
	int res=0;
	int cnt=0;
	rep0(1000){
		int cur=i;
		bool ok=1;
		for(int j=0;j<a.ln;j++){
			res++;
			if(a[j]== '+'){
				cur++;
			}else{
				cur--;
			}
			if(cur<0){
				ok=false;
				break;
			}
		}

		if(ok)break;
	}
	return res;
}

int fast(string a){
	int bal=0;
	int mini=0;
	int meat=1;
	bool notfound=1;
	map<int,int> temp;
	rep0(a.ln){
		if(a[i]=='+')bal++;
		else bal--;
		if(bal<0 and temp.find(bal)==temp.ed){
			temp[bal]=i+1;
		}
	}
	int res=a.ln;
	for(auto x:temp){

		res+=x.second;
	}

	return res;
}

string gen(int n){
	string res="";
	rep0(n){
		res.pb(rand()%2==0?'+':'-');
	}
	return res;
}
start main(){
	IOS
	srand(time(NULL));
	int t;
	cin >> t;
	while(t--){
		string a;
		cin >> a;
//		oo(bf(a))
		oo(fast(a))
	}
	//add_junk
	//add_junk

	//fsfsf
	// rep0(100){
		// string a=gen(5);
		// if(bf(a)!=fast(a)){
			// oo(a)
			// break;
		// }
	// }
	return 0;
}