#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const long long maxn=8001;
const long long inf=99999999999;
ll lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<ll> uid(l, r); return uid(rng); }

ll power(ll x, ll y){
	ll p=mode, res=1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

void solve(){

	ll n;
	cin>>n;
	vector<ll> v(n);
	for (int i=0;i<n;i++) cin>>v[i];

	ll r=0;
	while(r<n){
		vpll v2;
		ll start=r;
		while(r<n && v[r]!=0){
			v2.pb({v[r], r});
			r++;
		}
		sort(v2.rbegin(), v2.rend());
		if (v2.size()==0){
			if (r<n && v[r]==0) cout<<0<<endl;
		}
		else if (v2.size()==1){
			cout<<"pushStack"<<endl;
			if (r<n && v[r]==0) cout<<1<<" "<<"popStack"<<endl;
		}
		else if (v2.size()==2){
			cout<<"pushStack"<<endl;
			cout<<"pushQueue"<<endl;
			if (r<n && v[r]==0) cout<<2<<" "<<"popStack "<<"popQueue"<<endl;
		}
		else if (v2.size()==3){
			cout<<"pushStack"<<endl;
			cout<<"pushQueue"<<endl;
			cout<<"pushFront"<<endl;
			if (r<n && v[r]==0) cout<<3<<" "<<"popStack "<<"popQueue "<<"popFront"<<endl;
		}
		else{
			bool st=false, qu=false, dq=false;
			for (int j=start;j<(start+v2.size());j++){
				if (j==v2[0].S || j==v2[1].S || j==v2[2].S){
					if (st==false){
						st=true;
						cout<<"pushStack"<<endl;
					}
					else if (qu==false){
						qu=true;
						cout<<"pushQueue"<<endl;
					}
					else if (dq==false){
						dq=true;
						cout<<"pushFront"<<endl;
					}
				}
				else{
					cout<<"pushBack"<<endl;
				}
			}

			if (r<n && v[r]==0) cout<<3<<" "<<"popStack "<<"popQueue "<<"popFront"<<endl;
		}
		r++;
	}

	return;
}

int main(){

    #ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
    #endif
    srand(time(0));

    ios::sync_with_stdio(0);
    cin.tie(0);

	//T{ solve(); }
	solve();

	return 0;
}


#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const long long maxn=8001;
const long long inf=99999999999;
ll lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<ll> uid(l, r); return uid(rng); }

ll power(ll x, ll y){
	ll p=mode, res=1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

void solve(){

	ll n;
	cin>>n;
	vector<ll> v(n);
	for (int i=0;i<n;i++) cin>>v[i];

	ll r=0;
	while(r<n){
		vector<ll> v2;
		vector<string> vs;
		while(r<n && v[r]!=0){
			v2.pb(v[r]);
			r++;
		}
		sort(v2.rbegin(), v2.rend());
		if (v2.size()==0){
			cout<<0<<endl;
		}
		else if (v2.size()==1){
			cout<<"pushStack"<<endl;
			cout<<1<<" "<<"popStack"<<endl;
		}
		else if (v2.size()==2){
			cout<<"pushStack"<<endl;
			cout<<"pushQueue"<<endl;
			cout<<2<<" "<<"popStack "<<"popQueue"<<endl;
		}
		else if (v2.size()==3){
			cout<<"pushStack"<<endl;
			cout<<"pushQueue"<<endl;
			cout<<"pushFront"<<endl;
			cout<<3<<" "<<"popStack "<<"popQueue "<<"popFront"<<endl;
		}
		else{
			cout<<"pushStack"<<endl;
			cout<<"pushQueue"<<endl;
			cout<<"pushFront"<<endl;
			for (int j=4;j<=v2.size();j++) cout<<"pushBack"<<endl;
			cout<<3<<" "<<"popStack "<<"popQueue "<<"popFront"<<endl;
		}
		r++;
	}

	return;
}

int main(){

    #ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
    #endif
    srand(time(0));

    ios::sync_with_stdio(0);
    cin.tie(0);

	//T{ solve(); }
	solve();

	return 0;
}


#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const long long maxn=8001;
const long long inf=99999999999;
ll lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<ll> uid(l, r); return uid(rng); }

ll power(ll x, ll y){
	ll p=mode, res=1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

void solve(){

	ll n;
	cin>>n;
	ll st=0, qu=0, dqF=0, dqB=0;
	for (int i=0;i<n;i++){
		ll a;
		cin>>a;
		if (a==0){
			set<ll> s;
			if (st!=0) s.insert(st);
			if (qu!=0) s.insert(qu);
			if (dqF!=0 && dqB!=0) s.insert(max(dqF, dqB));
			else if (dqF!=0) s.insert(dqF);
			else if (dqB!=0) s.insert(dqB);

			cout<<s.size()<<" ";
			for (auto j:s){
				if (j==st) cout<<"popStack ";
				else if (j==qu) cout<<"popQueue ";
				else if (j==dqF) cout<<"popFront ";
				else cout<<"popBack ";
			}
			cout<<endl;
			st=0;
			qu=0;
			dqF=0;
			dqB=0;
		}
		else{
			if (st==0){
				cout<<"pushStack"<<endl;
				st=a;
			}
			else if (qu==0){
				cout<<"pushQueue"<<endl;
				qu=a;
			}
			else if (dqF==0){
				cout<<"pushFront"<<endl;
				dqF=a;
			}
			else if (dqB==0){
				cout<<"pushBack"<<endl;
				dqB=a;
			}
			else if (st<a){
				cout<<"pushStack"<<endl;
				st=a;
			}
			else if (qu<a){
				cout<<"pushQueue"<<endl;
				qu=a;
			}
			else if (dqF<a){
				cout<<"pushFront"<<endl;
				dqF=a;
			}
			else if (dqB<a){
				cout<<"pushBack"<<endl;
				dqB=a;
			}
			else if (st<qu && st<dqF && st<dqB){
				cout<<"pushStack"<<endl;
				st=a;
			}
			else if (qu<dqF && qu<dqB){
				cout<<"pushQueue"<<endl;
				qu=a;
			}
			else if (dqF<dqB){
				cout<<"pushFront"<<endl;
				dqF=a;
			}
			else{
				cout<<"pushBack"<<endl;
				dqB=a;
			}
		}
	}

	return;
}

int main(){

    #ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
    #endif
    srand(time(0));

    ios::sync_with_stdio(0);
    cin.tie(0);

	//T{ solve(); }
	solve();

	return 0;
}


#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const long long maxn=8001;
const long long inf=99999999999;
ll lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<ll> uid(l, r); return uid(rng); }

ll power(ll x, ll y){
	ll p=mode, res=1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

void solve(){

	ll n;
	cin>>n;
	vector<ll> v(n);
	for (int i=0;i<n;i++) cin>>v[i];

	ll r=0;
	while(r<n){
		vector<ll> v2;
		vector<string> vs;
		while(v[r]!=0){
			v2.pb(v[r]);
			r++;
		}
		sort(v2.rbegin(), v2.rend());
		if (v2.size()==0){
			cout<<0<<endl;
		}
		else if (v2.size()==1){
			cout<<"pushStack"<<endl;
			cout<<1<<" "<<"popStack"<<endl;
		}
		else if (v2.size()==2){
			cout<<"pushStack"<<endl;
			cout<<"pushQueue"<<endl;
			cout<<2<<" "<<"popStack "<<"popQueue"<<endl;
		}
		else if (v2.size()==3){
			cout<<"pushStack"<<endl;
			cout<<"pushQueue"<<endl;
			cout<<"pushFront"<<endl;
			cout<<3<<" "<<"popStack "<<"popQueue "<<"popFront"<<endl;
		}
		else{
			cout<<"pushStack"<<endl;
			cout<<"pushQueue"<<endl;
			cout<<"pushFront"<<endl;
			for (int j=4;j<=v2.size();j++) cout<<"pushBack"<<endl;
			cout<<3<<" "<<"popStack "<<"popQueue "<<"popFront"<<endl;
		}
		r++;
	}

	return;
}

int main(){

    #ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
    #endif
    srand(time(0));

    ios::sync_with_stdio(0);
    cin.tie(0);

	//T{ solve(); }
	solve();

	return 0;
}


#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const long long maxn=8001;
const long long inf=99999999999;
ll lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<ll> uid(l, r); return uid(rng); }

ll power(ll x, ll y){
	ll p=mode, res=1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

void solve(){

	ll n;
	cin>>n;
	ll st=0, qu=0, dqF=0, dqB=0;
	for (int i=0;i<n;i++){
		ll a;
		cin>>a;
		if (a==0){
			set<ll> s;
			if (st!=0) s.insert(st);
			if (qu!=0) s.insert(qu);
			if (dqF!=0 && dqB!=0) s.insert(max(dqF, dqB));
			else if (dqF!=0) s.insert(dqF);
			else if (dqB!=0) s.insert(dqB);

			cout<<s.size();
			for (auto j:s){
				if (j==st) cout<<" popStack";
				else if (j==qu) cout<<" popQueue";
				else if (j==dqF) cout<<" popFront";
				else cout<<" popBack";
			}
			cout<<endl;
			st=0;
			qu=0;
			dqF=0;
			dqB=0;
		}
		else{
			if (st==0){
				cout<<"pushStack"<<endl;
				st=a;
			}
			else if (qu==0){
				cout<<"pushQueue"<<endl;
				qu=a;
			}
			else if (dqF==0){
				cout<<"pushFront"<<endl;
				dqF=a;
			}
			else if (dqB==0){
				cout<<"pushBack"<<endl;
				dqB=a;
			}
			else if (st<a){
				cout<<"pushStack"<<endl;
				st=a;
			}
			else if (qu<a){
				cout<<"pushQueue"<<endl;
				qu=a;
			}
			else if (dqF<a){
				cout<<"pushFront"<<endl;
				dqF=a;
			}
			else if (dqB<a){
				cout<<"pushBack"<<endl;
				dqB=a;
			}
			else if (st<qu && st<dqF && st<dqB){
				cout<<"pushStack"<<endl;
				st=a;
			}
			else if (qu<dqF && qu<dqB){
				cout<<"pushQueue"<<endl;
				qu=a;
			}
			else if (dqF<dqB){
				cout<<"pushFront"<<endl;
				dqF=a;
			}
			else{
				cout<<"pushBack"<<endl;
				dqB=a;
			}
		}
	}

	return;
}

int main(){

    #ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
    #endif
    srand(time(0));

    ios::sync_with_stdio(0);
    cin.tie(0);

	//T{ solve(); }
	solve();

	return 0;
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;

	int count_q = 0, count_st = 0, count_d = 0;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if (count_q * count_st * count_d > 0) cout<<3;
				else if(count_q * count_st > 0 || count_q * count_d > 0 || count_st * count_d > 0) cout<<2;
				else cout <<1;
				if(count_q > 0){
					cout<<" popQueue";
					count = 0;
					count_q = 0;
					while(!q.empty()){
						q.pop();
					}
				}
				if(count_st > 0){
					count_st  = 0;
					cout<<" popStack";
					while(!st.empty()){
						st.pop();
					}
					count = 0;
				}
				if(count_d > 0){
					count_d = 0;
					if(d.front() > d.back()){
						cout<<" popFront";
						while(!d.empty()){
							d.pop_front();
						}
					}
					else{
						cout<<" popBack";
						while (d.empty()){
							d.pop_back();
						}
					}
					count = 0;
				}
				cout<<endl;
			}
		}
		else{
			if(q.empty()) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(st.empty()) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(d.empty()) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
				}
				count_d ++;
			}
			else if(A >= st.top()) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(A >= d.back()) {
				d.push_back(A);
				cout<<"pushBack"<<endl;
				count_d ++;
			}
			else if(A >= d.front()) {
				d.push_front(A);
				cout<<"pushFront"<<endl;
				count_d ++;
			}
			else {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int a[100000 + 5];

int main(){
	int n, A, count = 0, y = 0;
	cin>>n;

	int MAX = 0;

	int count_q = 0, count_st = 0, count_d = 0, Max_st = MAX, Max_q = MAX, Max_d = MAX;

	for(int i = 0; i < n; ++i){
		cin>>a[i];
		if(a[i] != 0){
			if(Max_d < A) Max_d = a[i];
			else if(Max_q < A) Max_q = a[i];
			else if(Max_st < A) Max_st = a[i];
		}else{
			for (int j = y; j < i; ++j){
				if(a[j] == Max_q){
					cout<<"pushQueue"<<endl;
				}
				else if(a[j] == Max_d){
					cout<<"pushBack"<<endl;
				}
				else if(a[j] == Max_st){
					cout<<"pushStack"<<endl;
				}
				else{
					cout<<"pushFront"<<endl;
				}
			}
			if(Max_st * Max_q * Max_d > 0){
				cout<<3<<" popStack popQueue popBack"<<endl;
			}
			else if(Max_q * Max_d > 0){
				cout<<2<<" popQueue popBack"<<endl;
			}
			else{
				cout<<1<<" popBack"<<endl;
			}
			Max_st = 0; Max_q = 0; Max_d = 0;
		}
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;

	int count_q = 0, count_st = 0, count_d = 0;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if (count_q * count_st * count_d > 0) cout<<3;
				else if(count_q * count_st > 0 || count_q * count_d > 0 || count_st * count_d > 0) cout<<2;
				else cout <<1;
				if(count_q > 0){
					count_q --;
					cout<<" popQueue";
					q.pop();
					count--;
				}
				if(count_st > 0){
					count_st --;
					cout<<" popStack";
					st.pop();
					count--;
				}
				if(count_d > 0){
					count_d --;
					if(d.front() > d.back()){
						cout<<" popFront";
						d.pop_front();
					}
					else{
						cout<<" popBack";
						d.pop_back();
					}
					count--;
				}
				cout<<endl;
			}
		}
		else{
			if(count % 3 == 0) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(count % 3 == 1) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(count % 3 == 2) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
				}
				count_d ++;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int a[100000 + 5];

int main(){
	int n, count = 0, y = 0;
	cin>>n;

	int MAX = 0;

	int count_q = 0, count_st = 0, count_d = 0, Max_st = MAX, Max_q = MAX, Max_d = MAX, x_q, x_d, x_st;

	for(int i = 0; i < n; ++i){
		cin>>a[i];
		if(a[i] != 0){
			if(Max_d < a[i]) {
				Max_st = Max_q;
				Max_q = Max_d;
				Max_d = a[i];
				x_st = x_q;
				x_q = x_d;
				x_d = i;
			}
			else if(Max_q < a[i]){
				Max_st = Max_q;
				Max_q = a[i];
				x_st = x_q;
				x_q = i;
			}
			else if(Max_st < a[i]) {
				Max_st = a[i];
				x_st = i;
			}
		}else{
			for (int j = y; j < i; ++j){
				if(j == x_q){
					cout<<"pushQueue"<<endl;
				}
				else if(j == x_d){
					cout<<"pushBack"<<endl;
				}
				else if(j == x_st){
					cout<<"pushStack"<<endl;
				}
				else{
					cout<<"pushFront"<<endl;
				}
			}
			if(Max_st > 0 && Max_q > 0 && Max_d > 0){
				cout<<3<<" popStack popQueue popBack"<<endl;
			}
			else if(Max_q > 0 && Max_d > 0){
				cout<<2<<" popQueue popBack"<<endl;
			}
			else if(Max_d > 0){
				cout<<1<<" popBack"<<endl;
			}
			else {
				cout<<0<<endl;
			}
			Max_st = 0; Max_q = 0; Max_d = 0;
			y = i + 1;
		}
	}

	if(Max_q + Max_d + Max_st > 0){
		for (int i = y; i < n; ++i){
			cout<<"pushQueue"<<endl;
		}
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;

	int count_q = 0, count_st = 0, count_d = 0, Min_st, Min_b, Min_fr;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if (count_q * count_st * count_d > 0) cout<<3;
				else if(count_q * count_st > 0 || count_q * count_d > 0 || count_st * count_d > 0) cout<<2;
				else cout <<1;
				if(count_q > 0){
					cout<<" popQueue";
					count = 0;
					count_q = 0;
					while(!q.empty()){
						q.pop();
					}
				}
				if(count_st > 0){
					count_st  = 0;
					cout<<" popStack";
					while(!st.empty()){
						st.pop();
					}
					count = 0;
				}
				if(count_d > 0){
					count_d = 0;
					if(d.front() > d.back()){
						cout<<" popFront";
						while(!d.empty()){
							d.pop_front();
						}
					}
					else{
						cout<<" popBack";
						while (d.empty()){
							d.pop_back();
						}
					}
					count = 0;
				}
				cout<<endl;
			}
		}
		else{
			if(q.empty()) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(st.empty()) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
				Min_st = A;
			}
			else if(d.empty()) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
					Min_b = A;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
					Min_fr = A;
				}
				count_d ++;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_st) {
				st.push(A);
				Min_st = A;
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_b) {
				d.push_back(A);
				Min_b = A;
				cout<<"pushBack"<<endl;
				count_d ++;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_fr) {
				d.push_front(A);
				Min_fr = A;
				cout<<"pushFront"<<endl;
				count_d ++;
			}
			else {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;
	int MAX = 1e5 + 5;

	int count_q = 0, count_st = 0, count_d = 0, Min_st = MAX, Min_b = MAX, Min_fr = MAX;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if (count_q * count_st * count_d > 0) cout<<3;
				else if(count_q * count_st > 0 || count_q * count_d > 0 || count_st * count_d > 0) cout<<2;
				else cout <<1;
				if(count_q > 0){
					cout<<" popQueue";
					count = 0;
					count_q = 0;
					while(!q.empty()){
						q.pop();
					}
				}
				if(count_st > 0){
					count_st  = 0;
					cout<<" popStack";
					while(!st.empty()){
						st.pop();
					}
					count = 0;
				}
				if(count_d > 0){
					count_d = 0;
					if(d.front() > d.back()){
						cout<<" popFront";
						while(!d.empty()){
							d.pop_front();
						}
					}
					else{
						cout<<" popBack";
						while (d.empty()){
							d.pop_back();
						}
					}
					count = 0;
				}
				cout<<endl;
			}
		}
		else{
			if(d.empty()) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
					Min_b = A;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
					Min_fr = A;
				}
				count_d ++;
			}
			else if(st.empty()) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
				Min_st = A;
			}
			else if(q.empty()) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_st && Min_st < A) {
				st.push(A);
				Min_st = A;
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_b && Min_b < A) {
				d.push_back(A);
				Min_b = A;
				cout<<"pushBack"<<endl;
				count_d ++;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_fr && Min_fr < A) {
				d.push_front(A);
				Min_fr = A;
				cout<<"pushFront"<<endl;
				count_d ++;
			}
			else {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;

	int count_q = 0, count_st = 0, count_d = 0;

	for(int i = 0; i < n; ++i){
		cout<<count<<endl;
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if (count_q * count_st * count_d > 0) cout<<3;
				else if(count_q * count_st > 0 || count_q * count_d > 0 || count_st * count_d > 0) cout<<2;
				else cout <<1;
				if(count_q > 0){
					cout<<" popQueue";
					count = 0;
					count_q = 0;
					while(!q.empty()){
						q.pop();
					}
				}
				if(count_st > 0){
					count_st  = 0;
					cout<<" popStack";
					while(!st.empty()){
						st.pop();
					}
					count = 0;
				}
				if(count_d > 0){
					count_d = 0;
					if(d.front() > d.back()){
						cout<<" popFront";
						while(!d.empty()){
							d.pop_front();
						}
					}
					else{
						cout<<" popBack";
						while (d.empty()){
							d.pop_back();
						}
					}
					count = 0;
				}
				cout<<endl;
			}
		}
		else{
			if(count == 0 ) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(count == 1) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(count == 2) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
				}
				count_d ++;
			}
			else if(A >= st.top()) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(A >= d.back()) {
				d.push_back(A);
				cout<<"pushBack"<<endl;
				count_d ++;
			}
			else if(A >= d.front()) {
				d.push_front(A);
				cout<<"pushFront"<<endl;
				count_d ++;
			}
			else {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;

	int count_q = 0, count_st = 0, count_d = 0;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if (count_q * count_st * count_d > 0) cout<<3;
				else if(count_q * count_st > 0 || count_q * count_d > 0 || count_st * count_d > 0) cout<<2;
				else cout <<1;
				if(count_q > 0){
					count_q --;
					cout<<" popQueue ";
					q.pop();
					count--;
				}
				if(count_st > 0){
					count_st --;
					cout<<" popStack ";
					st.pop();
					count--;
				}
				if(count_d > 0){
					count_d --;
					if(d.front() > d.back()){
						cout<<" popFront ";
						d.pop_front();
					}
					else{
						cout<<" popBack ";
						d.pop_back();
					}
					count--;
				}
				cout<<endl;
			}
		}
		else{
			if(count % 3 == 0) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(count % 3 == 1) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(count % 3 == 2) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
				}
				count_d ++;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int a[100000 + 5];

int main(){
	int n, A, count = 0, y = 0;
	cin>>n;

	int MAX = 0;

	int count_q = 0, count_st = 0, count_d = 0, Max_st = MAX, Max_q = MAX, Max_d = MAX;

	for(int i = 0; i < n; ++i){
		cin>>a[i];
		if(a[i] != 0){
			if(Max_d < a[i]) {
				Max_st = Max_q;
				Max_q = Max_d;
				Max_d = a[i];
			}
			else if(Max_q < a[i]){
				Max_st = Max_q;
				Max_q = a[i];
			}
			else if(Max_st < a[i]) Max_st = a[i];
		}else{
			for (int j = y; j < i; ++j){
				if(a[j] == Max_q){
					cout<<"pushQueue"<<endl;
				}
				else if(a[j] == Max_d){
					cout<<"pushBack"<<endl;
				}
				else if(a[j] == Max_st){
					cout<<"pushStack"<<endl;
				}
				else{
					cout<<"pushFront"<<endl;
				}
			}
			if(Max_st * Max_q * Max_d > 0){
				cout<<3<<" popStack popQueue popBack"<<endl;
			}
			else if(Max_q * Max_d > 0){
				cout<<2<<" popQueue popBack"<<endl;
			}
			else if(Max_d > 0){
				cout<<1<<" popBack"<<endl;
			}
			else {
				cout<<0<<endl;
			}
			Max_st = 0; Max_q = 0; Max_d = 0;
			y = i + 1;
		}
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;

	int count_q = 0, count_st = 0, count_d = 0;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if (count_q * count_st * count_d > 0) cout<<3;
				else if(count_q * count_st > 0 || count_q * count_d > 0 || count_st * count_d > 0) cout<<2;
				else cout <<1;
				if(count_q > 0){
					cout<<" popQueue";
					count = 0;
					count_q = 0;
					while(!q.empty()){
						q.pop();
					}
				}
				if(count_st > 0){
					count_st  = 0;
					cout<<" popStack";
					while(!st.empty()){
						st.pop();
					}
					count = 0;
				}
				if(count_d > 0){
					count_d = 0;
					if(d.front() > d.back()){
						cout<<" popFront";
						while(!d.empty()){
							d.pop_front();
						}
					}
					else{
						cout<<" popBack";
						while (d.empty()){
							d.pop_back();
						}
					}
					count = 0;
				}
				cout<<endl;
			}
		}
		else{
			if(count % 3 == 0) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(count % 3 == 1) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(count % 3 == 2) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
				}
				count_d ++;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int a[100000 + 5];

int main(){
	int n, A, count = 0, y = 0;
	cin>>n;

	int MAX = 0;

	int count_q = 0, count_st = 0, count_d = 0, Max_st = MAX, Max_q = MAX, Max_d = MAX;

	for(int i = 0; i < n; ++i){
		cin>>a[i];
		if(a[i] != 0){
			if(Max_d < a[i]) Max_d = a[i];
			else if(Max_q < a[i]) Max_q = a[i];
			else if(Max_st < a[i]) Max_st = a[i];
		}else{
			for (int j = y; j < i; ++j){
				if(a[j] == Max_q){
					cout<<"pushQueue"<<endl;
				}
				else if(a[j] == Max_d){
					cout<<"pushBack"<<endl;
				}
				else if(a[j] == Max_st){
					cout<<"pushStack"<<endl;
				}
				else{
					cout<<"pushFront"<<endl;
				}
			}
			if(Max_st * Max_q * Max_d > 0){
				cout<<3<<" popStack popQueue popBack"<<endl;
			}
			else if(Max_q * Max_d > 0){
				cout<<2<<" popQueue popBack"<<endl;
			}
			else{
				cout<<1<<" popBack"<<endl;
			}
			Max_st = 0; Max_q = 0; Max_d = 0;
		}
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int a[100000 + 5];

int main(){
	int n, A, count = 0, y = 0;
	cin>>n;

	int MAX = 0;

	int count_q = 0, count_st = 0, count_d = 0, Max_st = MAX, Max_q = MAX, Max_d = MAX;

	for(int i = 0; i < n; ++i){
		cin>>a[i];
		if(a[i] != 0){
			if(Max_d < a[i]) Max_d = a[i];
			else if(Max_q < a[i]) Max_q = a[i];
			else if(Max_st < a[i]) Max_st = a[i];
		}else{
			for (int j = y; j < i; ++j){
				if(a[j] == Max_q){
					cout<<"pushQueue"<<endl;
				}
				else if(a[j] == Max_d){
					cout<<"pushBack"<<endl;
				}
				else if(a[j] == Max_st){
					cout<<"pushStack"<<endl;
				}
				else{
					cout<<"pushFront"<<endl;
				}
			}
			if(Max_st * Max_q * Max_d > 0){
				cout<<3<<" popStack popQueue popBack"<<endl;
			}
			else if(Max_q * Max_d > 0){
				cout<<2<<" popQueue popBack"<<endl;
			}
			else if(Max_d > 0){
				cout<<1<<" popBack"<<endl;
			}
			else {
				cout<<0<<endl;
			}
			Max_st = 0; Max_q = 0; Max_d = 0;
		}
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	int count_q = 0, count_st = 0, count_d = 0;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if(count_q > 0){
					count_q --;
					cout<<q.front()<<" popQueue"<<endl;
					q.pop();
					count--;
				}
				if(count_st > 0){
					count_st --;
					cout<<st.top()<<" popStack"<<endl;
					st.pop();
					count--;
				}
				if(count_d > 0){
					count_d --;
					if(d.front() > d.back()){
						cout<<d.front()<<" popFront"<<endl;
						d.pop_front();
					}
					else{
						cout<<d.back()<<" popBack"<<endl;
						d.pop_back();
					}
					count--;
				}
			}
		}
		else{
			if(count % 3 == 0) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(count % 3 == 1) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(count % 3 == 2) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
				}
				count_d ++;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int a[100000 + 5];

int main(){
	int n, A, count = 0, y = 0;
	cin>>n;

	int MAX = 0;

	int count_q = 0, count_st = 0, count_d = 0, Max_st = MAX, Max_q = MAX, Max_d = MAX;

	for(int i = 0; i < n; ++i){
		cin>>a[i];
		if(a[i] != 0){
			if(Max_d < a[i]) Max_d = a[i];
			else if(Max_q < a[i]) Max_q = a[i];
			else if(Max_st < a[i]) Max_st = a[i];
		}else{
			for (int j = y; j < i; ++j){
				if(a[j] == Max_q){
					cout<<"pushQueue"<<endl;
				}
				else if(a[j] == Max_d){
					cout<<"pushBack"<<endl;
				}
				else if(a[j] == Max_st){
					cout<<"pushStack"<<endl;
				}
				else{
					cout<<"pushFront"<<endl;
				}
			}
			if(Max_st * Max_q * Max_d > 0){
				cout<<3<<" popStack popQueue popBack"<<endl;
			}
			else if(Max_q * Max_d > 0){
				cout<<2<<" popQueue popBack"<<endl;
			}
			else if(Max_d > 0){
				cout<<1<<" popBack"<<endl;
			}
			else {
				cout<<0<<endl;
			}
			Max_st = 0; Max_q = 0; Max_d = 0;
			y = i + 1;
		}
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;

	int count_q = 0, count_st = 0, count_d = 0;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if (count_q * count_st * count_d > 0) cout<<3;
				else if(count_q * count_st > 0 || count_q * count_d > 0 || count_st * count_d > 0) cout<<2;
				else cout <<1;
				if(count_q > 0){
					count_q --;
					cout<<" popQueue";
					q.pop();
					count--;
				}
				if(count_st > 0){
					count_st --;
					cout<<" popStack";
					st.pop();
					count--;
				}
				if(count_d > 0){
					count_d --;
					if(d.front() > d.back()){
						cout<<" popFront";
						d.pop_front();
					}
					else{
						cout<<" popBack ";
						d.pop_back();
					}
					count--;
				}
				cout<<endl;
			}
		}
		else{
			if(count % 3 == 0) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(count % 3 == 1) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(count % 3 == 2) {
				if(count == 2 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
				}
				count_d ++;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int a[100000 + 5];

int main(){
	int n, A, count = 0, y = 0;
	cin>>n;

	int MAX = 0;

	int count_q = 0, count_st = 0, count_d = 0, Max_st = MAX, Max_q = MAX, Max_d = MAX;

	for(int i = 0; i < n; ++i){
		cin>>a[i];
		if(a[i] != 0){
			if(Max_d < A) Max_d = a[i];
			else if(Max_q < A) Max_q = a[i];
			else if(Max_st < A) Max_st = a[i];
		}else{
			for (int j = y; j < i; ++j){
				if(a[j] == Max_q){
					cout<<"pushQueue"<<endl;
				}
				else if(a[j] == Max_d){
					cout<<"pushBack"<<endl;
				}
				else if(a[j] == Max_st){
					cout<<"pushStack"<<endl;
				}
				else{
					cout<<"pushFront"<<endl;
				}
			}
			if(Max_st * Max_q * Max_d > 0){
				cout<<3<<" popStack popQueue popBack"<<endl;
			}
			else if(Max_q * Max_d > 0){
				cout<<2<<" popQueue popBack"<<endl;
			}
			else{
				cout<<1<<"popBack"<<endl;
			}
		}
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;

	int count_q = 0, count_st = 0, count_d = 0, Min_st, Min_b, Min_fr;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if (count_q * count_st * count_d > 0) cout<<3;
				else if(count_q * count_st > 0 || count_q * count_d > 0 || count_st * count_d > 0) cout<<2;
				else cout <<1;
				if(count_q > 0){
					cout<<" popQueue";
					count = 0;
					count_q = 0;
					while(!q.empty()){
						q.pop();
					}
				}
				if(count_st > 0){
					count_st  = 0;
					cout<<" popStack";
					while(!st.empty()){
						st.pop();
					}
					count = 0;
				}
				if(count_d > 0){
					count_d = 0;
					if(d.front() > d.back()){
						cout<<" popFront";
						while(!d.empty()){
							d.pop_front();
						}
					}
					else{
						cout<<" popBack";
						while (d.empty()){
							d.pop_back();
						}
					}
					count = 0;
				}
				cout<<endl;
			}
		}
		else{
			if(st.empty()) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
				Min_st = A;
			}

			else if(q.empty()) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(d.empty()) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
					Min_b = A;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
					Min_fr = A;
				}
				count_d ++;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_st && Min_st < A) {
				st.push(A);
				Min_st = A;
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_b && Min_b < A) {
				d.push_back(A);
				Min_b = A;
				cout<<"pushBack"<<endl;
				count_d ++;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_fr && Min_fr < A) {
				d.push_front(A);
				Min_fr = A;
				cout<<"pushFront"<<endl;
				count_d ++;
			}
			else {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	int count_q = 0, count_st = 0, count_d = 0;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if(count_q > 0){
					count_q --;
					cout<<q.front()<<" popQueue ";
					q.pop();
					count--;
				}
				if(count_st > 0){
					count_st --;
					cout<<st.top()<<" popStack ";
					st.pop();
					count--;
				}
				if(count_d > 0){
					count_d --;
					if(d.front() > d.back()){
						cout<<d.front()<<" popFront ";
						d.pop_front();
					}
					else{
						cout<<d.back()<<" popBack ";
						d.pop_back();
					}
					count--;
				}
				cout<<endl;
			}
		}
		else{
			if(count % 3 == 0) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(count % 3 == 1) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(count % 3 == 2) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
				}
				count_d ++;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;

	int count_q = 0, count_st = 0, count_d = 0, Min_st, Min_b, Min_fr;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if (count_q * count_st * count_d > 0) cout<<3;
				else if(count_q * count_st > 0 || count_q * count_d > 0 || count_st * count_d > 0) cout<<2;
				else cout <<1;
				if(count_q > 0){
					cout<<" popQueue";
					count = 0;
					count_q = 0;
					while(!q.empty()){
						q.pop();
					}
				}
				if(count_st > 0){
					count_st  = 0;
					cout<<" popStack";
					while(!st.empty()){
						st.pop();
					}
					count = 0;
				}
				if(count_d > 0){
					count_d = 0;
					if(d.front() > d.back()){
						cout<<" popFront";
						while(!d.empty()){
							d.pop_front();
						}
					}
					else{
						cout<<" popBack";
						while (d.empty()){
							d.pop_back();
						}
					}
					count = 0;
				}
				cout<<endl;
			}
		}
		else{
			if(q.empty()) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(st.empty()) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
				Min_st = A;
			}
			else if(d.empty()) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
					Min_b = A;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
					Min_fr = A;
				}
				count_d ++;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_st && Min_st < A) {
				st.push(A);
				Min_st = A;
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_b && Min_b < A) {
				d.push_back(A);
				Min_b = A;
				cout<<"pushBack"<<endl;
				count_d ++;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_fr && Min_fr < A) {
				d.push_front(A);
				Min_fr = A;
				cout<<"pushFront"<<endl;
				count_d ++;
			}
			else {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;

	int count_q = 0, count_st = 0, count_d = 0;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if (count_q * count_st * count_d > 0) cout<<3;
				else if(count_q * count_st > 0 || count_q * count_d > 0 || count_st * count_d > 0) cout<<2;
				else cout <<1;
				if(count_q > 0){
					cout<<" popQueue";
					count = 0;
					count_q = 0;
					while(!q.empty()){
						q.pop();
					}
				}
				if(count_st > 0){
					count_st  = 0;
					cout<<" popStack";
					while(!st.empty()){
						st.pop();
					}
					count = 0;
				}
				if(count_d > 0){
					count_d = 0;
					if(d.front() > d.back()){
						cout<<" popFront";
						while(!d.empty()){
							d.pop_front();
						}
					}
					else{
						cout<<" popBack";
						while (d.empty()){
							d.pop_back();
						}
					}
					count = 0;
				}
				cout<<endl;
			}
		}
		else{
			if(count == 0 ) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(count == 1) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(count == 2) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
				}
				count_d ++;
			}
			else if(A >= st.top()) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(A >= d.back()) {
				d.push_back(A);
				cout<<"pushBack"<<endl;
				count_d ++;
			}
			else if(A >= d.front()) {
				d.push_front(A);
				cout<<"pushFront"<<endl;
				count_d ++;
			}
			else {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int a[100000 + 5];

int main(){
	int n, count = 0, y = 0;
	cin>>n;

	int MAX = 0;

	int count_q = 0, count_st = 0, count_d = 0, Max_st = MAX, Max_q = MAX, Max_d = MAX;

	for(int i = 0; i < n; ++i){
		cin>>a[i];
		if(a[i] != 0){
			if(Max_d < a[i]) {
				Max_st = Max_q;
				Max_q = Max_d;
				Max_d = a[i];
			}
			else if(Max_q < a[i]){
				Max_st = Max_q;
				Max_q = a[i];
			}
			else if(Max_st < a[i]) Max_st = a[i];
		}else{
			for (int j = y; j < i; ++j){
				if(a[j] == Max_q){
					cout<<"pushQueue"<<endl;
				}
				else if(a[j] == Max_d){
					cout<<"pushBack"<<endl;
				}
				else if(a[j] == Max_st){
					cout<<"pushStack"<<endl;
				}
				else{
					cout<<"pushFront"<<endl;
				}
			}
			if(Max_st * Max_q * Max_d > 0){
				cout<<3<<" popStack popQueue popBack"<<endl;
			}
			else if(Max_q * Max_d > 0){
				cout<<2<<" popQueue popBack"<<endl;
			}
			else if(Max_d > 0){
				cout<<1<<" popBack"<<endl;
			}
			else {
				cout<<0<<endl;
			}
			Max_st = 0; Max_q = 0; Max_d = 0;
			y = i + 1;
		}
	}

	if(Max_q + Max_d + Max_st > 0){
		for (int i = y; i < n; ++i){
			cout<<"pushQueue"<<endl;
		}
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;

	int count_q = 0, count_st = 0, count_d = 0;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if (count_q * count_st * count_d > 0) cout<<3;
				else if(count_q * count_st > 0 || count_q * count_d > 0 || count_st * count_d > 0) cout<<2;
				else cout <<1;
				if(count_q > 0){
					count_q --;
					cout<<" popQueue";
					q.pop();
					count--;
				}
				if(count_st > 0){
					count_st --;
					cout<<" popStack";
					st.pop();
					count--;
				}
				if(count_d > 0){
					count_d --;
					if(d.front() > d.back()){
						cout<<" popFront";
						d.pop_front();
					}
					else{
						cout<<" popBack ";
						d.pop_back();
					}
					count--;
				}
				cout<<endl;
			}
		}
		else{
			if(count % 3 == 0) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(count % 3 == 1) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(count % 3 == 2) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
				}
				count_d ++;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;
	int MAX = 1e5 + 5;

	int count_q = 0, count_st = 0, count_d = 0, Min_st = MAX, Min_b = MAX, Min_fr = MAX;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if (count_q * count_st * count_d > 0) cout<<3;
				else if(count_q * count_st > 0 || count_q * count_d > 0 || count_st * count_d > 0) cout<<2;
				else cout <<1;
				if(count_q > 0){
					cout<<" popQueue";
					count = 0;
					count_q = 0;
					while(!q.empty()){
						q.pop();
					}
				}
				if(count_st > 0){
					count_st  = 0;
					cout<<" popStack";
					while(!st.empty()){
						st.pop();
					}
					count = 0;
				}
				if(count_d > 0){
					count_d = 0;
					if(d.front() > d.back()){
						cout<<" popFront";
						while(!d.empty()){
							d.pop_front();
						}
					}
					else{
						cout<<" popBack";
						while (d.empty()){
							d.pop_back();
						}
					}
					count = 0;
				}
				cout<<endl;
			}
		}
		else{
			if(st.empty()) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
				Min_st = A;
			}

			else if(q.empty()) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(d.empty()) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
					Min_b = A;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
					Min_fr = A;
				}
				count_d ++;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_st && Min_st < A) {
				st.push(A);
				Min_st = A;
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_b && Min_b < A) {
				d.push_back(A);
				Min_b = A;
				cout<<"pushBack"<<endl;
				count_d ++;
			}
			else if(min(Min_st, min(Min_b, Min_fr)) == Min_fr && Min_fr < A) {
				d.push_front(A);
				Min_fr = A;
				cout<<"pushFront"<<endl;
				count_d ++;
			}
			else {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int main(){
	int n, A, count = 0;
	cin>>n;

	bool flag = false;

	int count_q = 0, count_st = 0, count_d = 0;

	for(int i = 0; i < n; ++i){
		cin>>A;
		if(A == 0){
			if(count_q + count_st + count_d == 0) cout<<0<<endl;
			else{
				if(count_q > 0){
					count_q --;
					cout<<q.front()<<" popQueue ";
					q.pop();
					count--;
					flag = true;
				}
				if(count_st > 0){
					count_st --;
					if(flag) cout<<" popStack ";
					else cout<<st.top()<<" popStack ";
					st.pop();
					count--;
					flag = true;
				}
				if(count_d > 0){
					count_d --;
					if(d.front() > d.back()){
						if(flag) cout<<" popFront ";
						else cout<<d.front()<<" popFront ";
						d.pop_front();
					}
					else{
						if(flag) cout<<" popBack ";
						else cout<<d.back()<<" popBack ";
						d.pop_back();
					}
					count--;
				}
				cout<<endl;
			}
		}
		else{
			if(count % 3 == 0) {
				q.push(A);
				count_q ++;
				cout<<"pushQueue"<<endl;
			}
			else if(count % 3 == 1) {
				st.push(A);
				count_st ++;
				cout<<"pushStack"<<endl;
			}
			else if(count % 3 == 2) {
				if(d.size() == 0 || A > d.back()){
					d.push_back(A);
					cout<<"pushBack"<<endl;
				}
				else {
					d.push_front(A);
					cout<<"pushFront"<<endl;
				}
				count_d ++;
			}
		}
		count++;
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int a[100000 + 5];

int main(){
	int n, count = 0, y = 0;
	cin>>n;

	int MAX = 0;

	int count_q = 0, count_st = 0, count_d = 0, Max_st = MAX, Max_q = MAX, Max_d = MAX, x_q, x_d, x_st;

	for(int i = 0; i < n; ++i){
		cin>>a[i];
		if(a[i] != 0){
			if(Max_d < a[i]) {
				Max_st = Max_q;
				Max_q = Max_d;
				Max_d = a[i];
				x_st = x_q;
				x_q = x_d;
				x_d = i;
			}
			else if(Max_q < a[i]){
				Max_st = Max_q;
				Max_q = a[i];
				x_st = x_q;
				x_q = i;
			}
			else if(Max_st < a[i]) {
				Max_st = a[i];
				x_st = i;
			}
		}else{
			for (int j = y; j < i; ++j){
				if(j == x_q){
					cout<<"pushQueue"<<endl;
				}
				else if(j == x_d){
					cout<<"pushBack"<<endl;
				}
				else if(j == x_st){
					cout<<"pushStack"<<endl;
				}
				else{
					cout<<"pushFront"<<endl;
				}
			}
			if(Max_st * Max_q * Max_d > 0){
				cout<<3<<" popStack popQueue popBack"<<endl;
			}
			else if(Max_q * Max_d > 0){
				cout<<2<<" popQueue popBack"<<endl;
			}
			else if(Max_d > 0){
				cout<<1<<" popBack"<<endl;
			}
			else {
				cout<<0<<endl;
			}
			Max_st = 0; Max_q = 0; Max_d = 0;
			y = i + 1;
		}
	}

	if(Max_q + Max_d + Max_st > 0){
		for (int i = y; i < n; ++i){
			cout<<"pushQueue"<<endl;
		}
	}
}


#include <iostream>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

deque <int> d;
queue <int> q;
stack <int> st;

int a[100000 + 5];

int main(){
	int n, A, count = 0, y = 0;
	cin>>n;

	int MAX = 0;

	int count_q = 0, count_st = 0, count_d = 0, Max_st = MAX, Max_q = MAX, Max_d = MAX;

	for(int i = 0; i < n; ++i){
		cin>>a[i];
		if(a[i] != 0){
			if(Max_d < A) {
				Max_st = Max_q;
				Max_q = Max_d;
				Max_d = a[i];
			}
			else if(Max_q < a[i]){
				Max_st = Max_q;
				Max_q = a[i];
			}
			else if(Max_st < a[i]) Max_st = a[i];
		}else{
			for (int j = y; j < i; ++j){
				if(a[j] == Max_q){
					cout<<"pushQueue"<<endl;
				}
				else if(a[j] == Max_d){
					cout<<"pushBack"<<endl;
				}
				else if(a[j] == Max_st){
					cout<<"pushStack"<<endl;
				}
				else{
					cout<<"pushFront"<<endl;
				}
			}
			if(Max_st * Max_q * Max_d > 0){
				cout<<3<<" popStack popQueue popBack"<<endl;
			}
			else if(Max_q * Max_d > 0){
				cout<<2<<" popQueue popBack"<<endl;
			}
			else if(Max_d > 0){
				cout<<1<<" popBack"<<endl;
			}
			else {
				cout<<0<<endl;
			}
			Max_st = 0; Max_q = 0; Max_d = 0;
			y = i + 1;
		}
	}

	if(Max_q + Max_d + Max_st > 0){
		for (int i = y; i < n; ++i){
			cout<<"pushQueue"<<endl;
		}
	}
}


#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define sz size()
#define f first
#define s second
#define mp make_pair
#define kz ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1e9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector <int> vi;

const int N = 2e5;
int n, x;
string a[4] = {"pushStack", "pushQueue", "pushFront", "pushBack"}, b[4] = {"popStack", "popQueue", "popFront", "popBack"};
vector <int> v;

void solve(){
	if(v.size() <= 3){
		for(int i = 0; i < v.sz; i++)
			cout << a[i] << endl;
		printf("%d", v.sz);
		for(int i = 0; i < v.sz; i++)
			cout << " " << b[i];
		printf("\n");
	}else{
		int mx[4] = {-1, -1, -1, 0};
		for(int i = 0; i < v.size(); i++)
			if(v[i] > mx[2]){
				mx[2] = v[i];
				sort(mx, mx + 3);
			}
		for(int i = 0; i < v.size(); i++){
		for(int j = 0; j < 4; j++)
			if(j == 3 || v[i] == mx[j]){
				cout << a[j] << endl;
				mx[j] = -1;
			}
		}
		cout << 3 << " ";
		for(int i = 0; i < 3; i++)
			cout << b[i] << " ";
		cout << endl;
	}
	v.clear();
}

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
		scanf("%d", &x);
		if(x)
			v.pb(x);
		else solve();
    }
    for(int i = 0; i < v.size(); i++)
    	printf("pushStack\n");
	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define sz size()
#define f first
#define s second
#define mp make_pair
#define kz ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1e9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector <int> vi;

const int N = 2e5;
int n, x;
string a[4] = {"pushStack", "pushQueue", "pushFront", "pushBack"}, b[4] = {"popStack", "popQueue", "popFront", "popBack"};
vector <int> v;

void solve(){
	if(v.size() <= 3){
		for(int i = 0; i < v.sz; i++)
			cout << a[i] << endl;
		cout << v.size();
		for(int i = 0; i < v.sz; i++)
			cout << " " << b[i];
		cout << endl;
	}else{
		int mx[4] = {-1, -1, -1, 0};
		for(int i = 0; i < v.size(); i++)
			if(v[i] > mx[0]){
				mx[0] = v[i];
				sort(mx, mx + 3);
			}
		for(int i = 0; i < v.size(); i++){
		for(int j = 0; j < 4; j++)
			if(j == 3 || v[i] == mx[j]){
				cout << a[j] << endl;
				mx[j] = -1;
				break;
			}
		}
		cout << 3 << " ";
		for(int i = 0; i < 3; i++)
			cout << b[i] << " ";
		cout << endl;
	}
	v.clear();
}

int main(){
	cin >> n;
    for(int i = 1; i <= n; i++){
    	cin >> x;
		if(x)
			v.pb(x);
		else solve();
    }
    for(int i = 0; i < v.size(); i++)
    	cout << "pushBack\n";
	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define sz size()
#define f first
#define s second
#define mp make_pair
#define kz ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1e9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector <int> vi;

const int N = 2e5;
int n, x;
string a[4] = {"pushStack", "pushQueue", "pushFront", "pushBack"}, b[4] = {"popStack", "popQueue", "popFront", "popBack"};
vector <int> v;

void solve(){
	if(v.size() <= 3){
		for(int i = 0; i < v.sz; i++)
			cout << a[i] << endl;
		cout << v.size();
		for(int i = 0; i < v.sz; i++)
			cout << " " << b[i];
		cout << endl;
	}else{
		int mx[4] = {-1, -1, -1, 0};
		for(int i = 0; i < v.size(); i++)
			if(v[i] > mx[0]){
				mx[0] = v[i];
				sort(mx, mx + 3);
			}
		for(int i = 0; i < v.size(); i++){
		for(int j = 0; j < 4; j++)
			if(j == 3 || v[i] == mx[j]){
				cout << a[j] << endl;
				mx[j] = -1;
				break;
			}
		}
		cout << 3;
		for(int i = 0; i < 3; i++)
			cout << " " << b[i];
		cout << endl;
	}
	v.clear();
}

int main(){
	cin >> n;
    for(int i = 1; i <= n; i++){
    	cin >> x;
		if(x)
			v.pb(x);
		else solve();
    }
    for(int i = 0; i < v.size(); i++)
    	cout << "pushBack\n";
	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define sz size()
#define f first
#define s second
#define mp make_pair
#define kz ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1e9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector <int> vi;

const int N = 2e5;
int n, x;
string a[4] = {"pushStack", "pushQueue", "pushFront", "pushBack"}, b[4] = {"popStack", "popQueue", "popFront", "popBack"};
vector <int> v;

void solve(){
	if(v.size() <= 3){
		for(int i = 0; i < v.sz; i++)
			cout << a[i] << endl;
		cout << v.size();
		for(int i = 0; i < v.sz; i++)
			cout << " " << b[i];
		cout << endl;
	}else{
		int mx[4] = {-1, -1, -1, 0};
		for(int i = 0; i < v.size(); i++)
			if(v[i] > mx[2]){
				mx[2] = v[i];
				sort(mx, mx + 3);
			}
		for(int i = 0; i < v.size(); i++){
		for(int j = 0; j < 4; j++)
			if(j == 3 || v[i] == mx[j]){
				cout << a[j] << endl;
				mx[j] = -1;
			}
		}
		cout << 3 << " ";
		for(int i = 0; i < 3; i++)
			cout << b[i] << " ";
		cout << endl;
	}
	v.clear();
}

int main(){
	cin >> n;
    for(int i = 1; i <= n; i++){
    	cin >> x;
		if(x)
			v.pb(x);
		else solve();
    }
    for(int i = 0; i < v.size(); i++)
    	cout << "pushBack\n";
	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define sz size()
#define f first
#define s second
#define mp make_pair
#define kz ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1e9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector <int> vi;

const int N = 2e5;
int n, x;
string a[4] = {"pushStack", "pushQueue", "pushFront", "pushBack"}, b[4] = {"popStack", "popQueue", "popFront", "popBack"};
vector <int> v;

void solve(){
	if(v.size() <= 3){
		for(int i = 0; i < v.sz; i++)
			cout << a[i] << endl;
		printf("%d ", v.sz);
		for(int i = 0; i < v.sz; i++)
			cout << b[i] << " ";
		printf("\n");
	}else{
		int mx[4] = {-1, -1, -1, 0};
		for(int i = 0; i < v.size(); i++)
			if(v[i] > mx[2]){
				mx[2] = v[i];
				sort(mx, mx + 3);
			}
		for(int i = 0; i < v.size(); i++){
		for(int j = 0; j < 4; j++)
			if(j == 3 || v[i] == mx[j]){
				cout << a[j] << endl;
				mx[j] = -1;
			}
		}
		cout << 3 << " ";
		for(int i = 0; i < 3; i++)
			cout << b[i] << " ";
		cout << endl;
	}
	v.clear();
}

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
		scanf("%d", &x);
		if(x)
			v.pb(x);
		else solve();
    }
    for(int i = 0; i < v.size(); i++)
    	printf("pushStack\n");
	return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

string out[] = {"pushStack", "pushQueue", "pushBack", "popStack", "popQueue", "popFront"};
vector<int> cnt[N];
set<pair<int, int> > st;
void solve(int idx){
    for(int i = 0 ; i < 3 && st.size() ; ++i){
        cnt[idx].emplace_back(i + 3);
        cnt[(*st.rbegin()).second].emplace_back(i);
        st.erase(st.find(*st.rbegin()));
    }
}

bool vis[N];

int main(){
    int n;
    scanf("%d", &n);
    memset(cnt, -1, n * sizeof cnt[0]);
    for(int i = 0 ; i < n ; ++i){
        int x;
        scanf("%d", &x);
        if(x == 0)
            solve(i), vis[i] = true;
        else
            st.emplace(x, i);
    }
    for(int i = 0 ; i < n ; ++i){
        if(vis[i]){
            printf("%d", cnt[i].size());
            for(auto j : cnt[i])printf(" %s", out[j].c_str());
            puts("");
        }
        else{
            if(cnt[i].empty())puts("pushFront");
            else printf("%s\n", out[cnt[i][0]].c_str());
        }
    }
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

int cnt[N];
set<pair<int, int> > st;
int solve(int idx){
    ++cnt[idx];
    for(int i = 0 ; i < 3 && st.size() ; ++i){
        ++cnt[idx];
        cnt[(*st.rbegin()).second] = -2;
        st.erase(st.find(*st.rbegin()));
    }
}

int main(){
    int n;
    scanf("%d", &n);
    memset(cnt, -1, n * sizeof cnt[0]);
    for(int i = 0 ; i < n ; ++i){
        int x;
        scanf("%d", &x);
        if(x == 0)
            solve(i);
        else
            st.emplace(x, i);
    }
    for(int i = 0 ; i < n ; ++i){
        if(cnt[i] == -2)puts("pushStack");
        else if(cnt[i] == -1)puts("pushQueue");
        else{
            printf("%d ", cnt[i]);
            while(cnt[i]--)printf("popStack ");
            puts("");
        }
    }
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

string out[] = {"pushStack", "pushQueue", "pushFront", "popStack", "popQueue", "popFront"};
vector<int> cnt[N];
set<pair<int, int> > st;
void solve(int idx){
    for(int i = 0 ; i < 3 && st.size() ; ++i){
        cnt[idx].emplace_back(i + 3);
        cnt[(*st.rbegin()).second].emplace_back(i);
        st.erase(st.find(*st.rbegin()));
    }
}

bool vis[N];

int main(){
    int n;
    scanf("%d", &n);
    memset(cnt, -1, n * sizeof cnt[0]);
    for(int i = 0 ; i < n ; ++i){
        int x;
        scanf("%d", &x);
        if(x == 0)
            solve(i), vis[i] = true;
        else
            st.emplace(x, i);
    }
    for(int i = 0 ; i < n ; ++i){
        if(vis[i]){
            printf("%d", cnt[i].size());
            for(auto j : cnt[i])printf(" %s", out[j].c_str());
            puts("");
        }
        else{
            if(cnt[i].empty())puts("pushStack");
            else printf("%s\n", out[cnt[i][0]].c_str());
        }
    }
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

string out[] = {"pushStack", "pushQueue", "pushFront", "popStack", "popQueue", "popFront"};
vector<int> cnt[N];
set<pair<int, int> > st;
void solve(int idx){
    for(int i = 0 ; i < 3 && st.size() ; ++i){
        cnt[idx].emplace_back(i + 3);
        cnt[(*st.rbegin()).second].emplace_back(i);
        st.erase(st.find(*st.rbegin()));
    }
}

bool vis[N];

int main(){
    int n;
    scanf("%d", &n);
    memset(cnt, -1, n * sizeof cnt[0]);
    for(int i = 0 ; i < n ; ++i){
        int x;
        scanf("%d", &x);
        if(x == 0)
            solve(i), vis[i] = true;
        else
            st.emplace(x, i);
    }
    for(int i = 0 ; i < n ; ++i){
        if(vis[i]){
            printf("%d", cnt[i].size());
            for(auto j : cnt[i])printf(" %s", out[j].c_str());
            puts("");
        }
        else{
            if(cnt[i].empty())puts("pushBack");
            else printf("%s\n", out[cnt[i][0]].c_str());
        }
    }
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

string out[] = {"pushStack", "pushQueue", "pushFront", "popStack", "popQueue", "popFront", "pushBack"};
vector<int> cnt[N];
set<pair<int, int> > st;
void solve(int idx){
    for(int i = 0 ; i < 3 && st.size() ; ++i){
        cnt[idx].emplace_back(i + 3);
        cnt[(*st.rbegin()).second].emplace_back(i);
        st.erase(st.find(*st.rbegin()));
    }
    while(st.size()){
        cnt[(*st.rbegin()).second].emplace_back(6);
        st.erase(st.find(*st.rbegin()));
    }
}

bool vis[N];

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0 ; i < n ; ++i){
        int x;
        scanf("%d", &x);
        if(x == 0)
            solve(i), vis[i] = true;
        else
            st.emplace(x, i);
    }
    while(st.size()){
        cnt[(*st.rbegin()).second].emplace_back(6);
        st.erase(st.find(*st.rbegin()));
    }
    for(int i = 0 ; i < n ; ++i){
        if(vis[i]){
            printf("%d", cnt[i].size());
            for(auto j : cnt[i])printf(" %s", out[j].c_str());
            puts("");
        }
        else
            printf("%s\n", out[cnt[i][0]].c_str());
    }
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

int cnt[N];
set<pair<int, int> > st;
void solve(int idx){
    ++cnt[idx];
    for(int i = 0 ; i < 3 && st.size() ; ++i){
        ++cnt[idx];
        cnt[(*st.rbegin()).second] = -2;
        st.erase(st.find(*st.rbegin()));
    }
}

int main(){
    int n;
    scanf("%d", &n);
    memset(cnt, -1, n * sizeof cnt[0]);
    for(int i = 0 ; i < n ; ++i){
        int x;
        scanf("%d", &x);
        if(x == 0)
            solve(i);
        else
            st.emplace(x, i);
    }
    for(int i = 0 ; i < n ; ++i){
        if(cnt[i] == -2)puts("pushStack");
        else if(cnt[i] == -1)puts("pushQueue");
        else{
            printf("%d", cnt[i]);
            while(cnt[i]--)printf(" popStack");
            puts("");
        }
    }
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

string out[] = {"pushStack", "pushQueue", "pushFront", "popStack", "popQueue", "popFront"};
vector<int> cnt[N];
set<pair<int, int> > st;
void solve(int idx){
    for(int i = 0 ; i < 3 && st.size() ; ++i){
        cnt[idx].emplace_back(i + 3);
        cnt[(*st.rbegin()).second].emplace_back(i);
        st.erase(st.find(*st.rbegin()));
    }
}

bool vis[N];

int main(){
    int n;
    scanf("%d", &n);
    memset(cnt, -1, n * sizeof cnt[0]);
    for(int i = 0 ; i < n ; ++i){
        int x;
        scanf("%d", &x);
        if(x == 0)
            solve(i), vis[i] = true;
        else
            st.emplace(x, i);
    }
    for(int i = 0 ; i < n ; ++i){
        if(vis[i]){
            printf("%d", cnt[i].size());
            for(auto j : cnt[i])printf(" %s", out[j].c_str());
            puts("");
        }
        else{
            if(cnt[i].empty())puts("pushQueue");
            else printf("%s\n", out[cnt[i][0]].c_str());
        }
    }
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

string out[] = {"pushStack", "pushQueue", "pushFront", "popStack", "popQueue", "popFront"};
vector<int> cnt[N];
set<pair<int, int> > st;
void solve(int idx){
    for(int i = 0 ; i < 3 && st.size() ; ++i){
        cnt[idx].emplace_back(i + 3);
        cnt[(*st.rbegin()).second].emplace_back(i);
        st.erase(st.find(*st.rbegin()));
    }
}

bool vis[N];

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0 ; i < n ; ++i){
        int x;
        scanf("%d", &x);
        if(x == 0)
            solve(i), vis[i] = true;
        else
            st.emplace(x, i);
    }
    for(int i = 0 ; i < n ; ++i){
        if(vis[i]){
            printf("%d", cnt[i].size());
            for(auto j : cnt[i])printf(" %s", out[j].c_str());
            puts("");
        }
        else{
            if(cnt[i].empty())puts("pushBack");
            else printf("%s\n", out[cnt[i][0]].c_str());
            if(cnt[i].size() > 1)assert(1 == 5);
        }
    }
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

string out[] = {"pushStack", "pushQueue", "pushFront", "popStack", "popQueue", "popFront"};
vector<int> cnt[N];
set<pair<int, int> > st;
void solve(int idx){
    for(int i = 0 ; i < 3 && st.size() ; ++i){
        cnt[idx].emplace_back(i + 3);
        cnt[(*st.rbegin()).second].emplace_back(i);
        st.erase(st.find(*st.rbegin()));
    }
}

bool vis[N];

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0 ; i < n ; ++i){
        int x;
        scanf("%d", &x);
        if(x == 0)
            solve(i), vis[i] = true;
        else
            st.emplace(x, i);
    }
    for(int i = 0 ; i < n ; ++i){
        if(vis[i]){
            printf("%d", cnt[i].size());
            for(auto j : cnt[i])printf(" %s", out[j].c_str());
            puts("");
        }
        else{
            if(cnt[i].empty())puts("pushBack");
            else printf("%s\n", out[cnt[i][0]].c_str());
        }
    }
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

string out[] = {"pushStack", "pushQueue", "pushFront", "popStack", "popQueue", "popFront"};
vector<int> cnt[N];
set<pair<int, int> > st;
void solve(int idx){
    for(int i = 0 ; i < 3 && st.size() ; ++i){
        cnt[idx].emplace_back(i + 3);
        cnt[(*st.rbegin()).second].emplace_back(i);
        st.erase(st.find(*st.rbegin()));
    }
}

bool vis[N];

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0 ; i < n ; ++i){
        int x;
        scanf("%d", &x);
        if(x == 0)
            solve(i), vis[i] = true;
        else
            st.insert(make_pair(x, i));
    }
    for(int i = 0 ; i < n ; ++i){
        if(vis[i]){
            printf("%d", cnt[i].size());
            for(auto j : cnt[i])printf(" %s", out[j].c_str());
            puts("");
        }
        else{
            if(cnt[i].empty())puts("pushBack");
            else printf("%s\n", out[cnt[i][0]].c_str());
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    int n,N=1e5+50;
    cin>>n;
    int typ[3]={0},arr[n],brr[N]={0},zr[n]={0};
    string out[4]={"popStack","popQueue","popFront","popBack"},in[4]={"pushStack","pushQueue","pushFront","pushBack"};
    priority_queue<int> pq;
    int x;
    for (int i=0;i<n;i++){
        cin>>x;
        arr[i]=x;
        if (x)
            pq.push(x);
        else{
            int ind=0;
            while(ind<3 && pq.size()){
             brr[pq.top()]++;
             pq.pop();
             ind++;
             zr[i]++;
            }
        }
    }
    int ind=0,ind2=0;
    for (int i=0;i<n;i++){
        if (arr[i]){
            if (brr[arr[i]]){
                cout<<in[ind%3];
                brr[arr[i]]--;
                ind++;
            }
            else
                cout<<in[3];
        }
        else{
            cout<<zr[i];
            while(zr[i]--){
                cout<<" "<<out[ind2%3];
                ind2++;
            }
        }
        cout<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    int n,N=1e5+50;
    cin>>n;
    int typ[3]={0},arr[n],brr[N]={0},zr[n]={0};
    string out[4]={"popStack","popQueue","popFront","popBack"},in[4]={"pushStack","pushQueue","pushFront","pushBack"};
    priority_queue<int> pq;
    int x;
    for (int i=0;i<n;i++){
        cin>>x;
        arr[i]=x;
        if (x)
            pq.push(x);
        else{
            int ind=0;
            while(ind<3 && pq.size()){
             brr[pq.top()]++;
             pq.pop();
             ind++;
             zr[i]++;
            }
        }
    }
    int ind=0,ind2=0;
    for (int i=0;i<n;i++){
        if (arr[i]){
            if (brr[arr[i]]){
                cout<<in[ind%3]<<" ";
                brr[arr[i]]--;
                ind++;
            }
            else
                cout<<in[3]<<" ";
        }
        else{
            cout<<zr[i]<<" ";
            while(zr[i]--){
                cout<<out[ind2%3]<<" ";
                ind2++;
            }
        }
        cout<<endl;
    }
    cout<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    int n,N=1e5+50;
    cin>>n;
    int typ[3]={0},arr[n],brr[N],zr[n]={0};
    string out[4]={"popStack","popQueue","popFront","popBack"},in[4]={"pushStack","pushQueue","pushFront","pushBack"};
    priority_queue<int> pq;
    int x;
    for (int i=0;i<n;i++){
        cin>>x;
        arr[i]=x;
        if (x)
            pq.push(x);
        else{
            int ind=0;
            while(ind<3 && pq.size()){
             brr[pq.top()]++;
             pq.pop();
             ind++;
             zr[i]++;
            }
        }
    }
    int ind=0,ind2=0;
    for (int i=0;i<n;i++){
        if (arr[i]){
            if (brr[arr[i]]){
                cout<<in[ind%3]<<" ";
                brr[arr[i]]--;
                ind++;
            }
            else
                cout<<in[3]<<" ";
        }
        else{
            cout<<zr[i]<<" ";
            while(zr[i]--){
                cout<<out[ind2%3]<<" ";
                ind2++;
            }
        }
        cout<<"\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    int n,N=1e5+50;
    cin>>n;
    int typ[3]={0},arr[n],brr[N]={0},zr[n]={0};
    string out[4]={"popStack","popQueue","popFront","popBack"},in[4]={"pushStack","pushQueue","pushFront","pushBack"};
    priority_queue<int> pq;
    int x;
    for (int i=0;i<n;i++){
        cin>>x;
        arr[i]=x;
        if (x)
            pq.push(x);
        else{
            int ind=0;
            while(ind<3 && pq.size()){
             brr[pq.top()]++;
             pq.pop();
             ind++;
             zr[i]++;
            }
            while(pq.size()){
                brr[pq.top()]--;
                pq.pop();
            }
        }
    }
    int ind=0,ind2=0;
    for (int i=0;i<n;i++){
        if (arr[i]){
            if (brr[arr[i]]){
                cout<<in[ind%3];
                brr[arr[i]]--;
                ind++;
            }
            else
                cout<<in[3];
        }
        else{
            cout<<zr[i];
            while(zr[i]--){
                cout<<" "<<out[ind2%3];
                ind2++;
            }
        }
        cout<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    int n,N=1e5+50;
    cin>>n;
    int typ[3]={0},arr[n],zr[n]={0};
    bool brr[n]={0};
    map<int,vector<int>> mp;
    string out[4]={"popStack","popQueue","popFront","popBack"},in[4]={"pushStack","pushQueue","pushFront","pushBack"};
    priority_queue<int> pq;
    int x;
    for (int i=0;i<n;i++){
        cin>>x;
        arr[i]=x;
        if (x){
            pq.push(x);
            mp[x].push_back(i);
        }
        else{
            int ind=0;
            while(ind<3 && pq.size()){
             brr[mp[pq.top()][mp[pq.top()].size()-1]]=true;
             mp[pq.top()].pop_back();
             pq.pop();
             ind++;
             zr[i]++;
            }
            while(pq.size())
                pq.pop();
            mp.clear();
        }
    }
    int ind=0,ind2=0;
    for (int i=0;i<n;i++){
        if (arr[i]){
            if (brr[i]){
                cout<<in[ind%3];\
                ind++;
            }
            else
                cout<<in[3];
        }
        else{
            cout<<zr[i];
            while(zr[i]--){
                cout<<" "<<out[ind2%3];
                ind2++;
            }
        }
        cout<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    int n,N=1e5+50;
    cin>>n;
    int typ[3]={0},arr[n],brr[N]={0},zr[n]={0};
    string out[4]={"popStack","popQueue","popFront","popBack"},in[4]={"pushStack","pushQueue","pushFront","pushBack"};
    priority_queue<int> pq;
    int x;
    for (int i=0;i<n;i++){
        cin>>x;
        arr[i]=x;
        if (x)
            pq.push(x);
        else{
            int ind=0;
            while(ind<3 && pq.size()){
             brr[pq.top()]++;
             pq.pop();
             ind++;
             zr[i]++;
            }
        }
    }
    int ind=0,ind2=0;
    for (int i=0;i<n;i++){
        if (arr[i]){
            if (brr[arr[i]]){
                cout<<in[ind%3]<<" ";
                brr[arr[i]]--;
                ind++;
            }
            else
                cout<<in[3]<<" ";
        }
        else{
            cout<<zr[i]<<" ";
            while(zr[i]--){
                cout<<out[ind2%3]<<" ";
                ind2++;
            }
        }
        cout<<"\n";
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    int n,N=1e5+50;
    cin>>n;
    int typ[3]={0},arr[n],brr[N]={0},zr[n]={0};
    string out[4]={"popStack","popQueue","popFront","popBack"},in[4]={"pushStack","pushQueue","pushFront","pushBack"};
    priority_queue<int> pq;
    int x;
    for (int i=0;i<n;i++){
        cin>>x;
        arr[i]=x;
        if (x)
            pq.push(x);
        else{
            int ind=0;
            while(ind<3 && pq.size()){
             brr[pq.top()]++;
             pq.pop();
             ind++;
             zr[i]++;
            }
            while(pq.size())
                pq.pop();
        }
    }
    int ind=0,ind2=0;
    for (int i=0;i<n;i++){
        if (arr[i]){
            if (brr[arr[i]]){
                cout<<in[ind%3];
                brr[arr[i]]--;
                ind++;
            }
            else
                cout<<in[3];
        }
        else{
            cout<<zr[i];
            while(zr[i]--){
                cout<<" "<<out[ind2%3];
                ind2++;
            }
        }
        cout<<endl;
    }

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)-v.begin()
#define lb(v,val) lower_bound(v.begin(),v.end(),val)-v.begin()
#define sortv(vec) sort(vec.begin(),vec.end())
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,n,d) for(ll i=0;i<n;i++)
#define fi first
#define se second
#define mt make_tuple
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9+7;
int ll_max=1e6;

int main() {
	//your code goes here
	IOS;
	ll n,m;
	ll j,y,z,x,T,i;
	ll k,h,t;
	cin>>n;
	set<pair<ll,ll>,greater<pair<ll,ll>> > q;
	ll cnt=0;
	rep(i,n){
	      cin>>x;
	      if(x!=0){
	            q.insert({x,cnt});
	            cnt++;
	      }
	      else{
	          if(cnt==0){
	                cout<<"0\n";
	                continue;
	          }

	          if(q.size()==1){
	                cout<<"pushStack\n1 popStack\n";

	          }
	          else if(q.size()==2){
	                cout<<"pushStack\npushQueue\n2 popStack popQueue\n";
	          }
	          else{
	                ll a,b,c;
	                a=(*q.begin()).se;
	                q.erase(q.begin());
	                b=(*q.begin()).se;
	                q.erase(q.begin());
	                c=(*q.begin()).se;
	                q.erase(q.begin());
	                rep(j,cnt){
	                      if(j==a)
	                      cout<<"pushStack\n";
	                      if(j==b)
	                      cout<<"pushQueue\n";
	                      if(j==c)
	                      cout<<"pushFront\n";
	                      else
	                      cout<<"pushBack\n";
	                }
	                cout<<"3 popStack popQueue popFront\n";

	          }
	          q.clear();
	          cnt=0;
	      }
	}
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)-v.begin()
#define lb(v,val) lower_bound(v.begin(),v.end(),val)-v.begin()
#define sortv(vec) sort(vec.begin(),vec.end())
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,n,d) for(ll i=0;i<n;i++)
#define fi first
#define se second
#define mt make_tuple
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9+7;
int ll_max=1e6;

int main() {
	//your code goes here
	IOS;
	ll n,m;
	ll j,y,z,x,T,i;
	ll k,h,t;
	cin>>n;
	set<pair<ll,ll>,greater<pair<ll,ll>> > q;
	ll cnt=0;
	rep(i,n){
	      cin>>x;
	      if(x!=0){
	            q.insert({x,cnt});
	            cnt++;
	      }
	      else{
	          if(cnt==0){
	                cout<<"0\n";
	                continue;
	          }

	          if(q.size()==1){
	                cout<<"pushStack\n1 popStack\n";

	          }
	          else if(q.size()==2){
	                cout<<"pushStack\npushQueue\n2 popStack popQueue\n";
	          }
	          else{
	                ll a,b,c;
	                a=(*q.begin()).se;
	                q.erase(q.begin());
	                b=(*q.begin()).se;
	                q.erase(q.begin());
	                c=(*q.begin()).se;
	                q.erase(q.begin());
	                rep(j,cnt){
	                      if(j==a)
	                      cout<<"pushStack\n";
	                      if(j==b)
	                      cout<<"pushQueue\n";
	                      if(j==c)
	                      cout<<"pushFront\n";
	                      if(j!=a&&j!=b&&j!=c)
	                      cout<<"pushBack\n";
	                }
	                cout<<"3 popStack popQueue popFront\n";

	          }
	          q.clear();
	          cnt=0;
	      }
	}
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)-v.begin()
#define lb(v,val) lower_bound(v.begin(),v.end(),val)-v.begin()
#define sortv(vec) sort(vec.begin(),vec.end())
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,n,d) for(ll i=0;i<n;i++)
#define fi first
#define se second
#define mt make_tuple
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9+7;
int ll_max=1e6;

int main() {
	//your code goes here
	IOS;
	ll n,m;
	ll j,y,z,x,T,i;
	ll k,h,t;
	cin>>n;
	set<pair<ll,ll>,greater<pair<ll,ll>> > q;
	ll cnt=0;
	rep(i,n){
	      cin>>x;
	      if(x!=0){
	            q.insert({x,cnt});
	            cnt++;
	      }
	      else{
	          if(cnt==0){
	                cout<<"0\n";
	                continue;
	          }

	          if(q.size()==1){
	                cout<<"pushStack\n1 popStack\n";

	          }
	          else if(q.size()==2){
	                cout<<"pushStack\npushQueue\n2 popStack popQueue\n";
	          }
	          else{
	                ll a,b,c;
	                a=(*q.begin()).se;
	                q.erase(q.begin());
	                b=(*q.begin()).se;
	                q.erase(q.begin());
	                c=(*q.begin()).se;
	                q.erase(q.begin());
	                rep(j,cnt){
	                      if(j==a)
	                      cout<<"pushStack\n";
	                      if(j==b)
	                      cout<<"pushQueue\n";
	                      if(j==c)
	                      cout<<"pushFront\n";
	                      if(j!=a&&j!=b&&j!=c)
	                      cout<<"pushBack\n";
	                }
	                cout<<"3 popStack popQueue popFront\n";

	          }
	          q.clear();
	          cnt=0;
	      }
	}
	rep(i,cnt){
	      cout<<"pushBack\n";
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

const string insertCommand[4] = {"pushStack","pushQueue","pushFront","pushBack"};
const string popCommand[4] = {"popStack","popQueue","popFront","popBack"};

set<pair<int,int>> s;

int lessThan3(bool flag)
{
	for (int i = 0; i < s.size(); ++i)
	{
		cout << insertCommand[i] << '\n';
	}

	cout << s.size();

	for (int i = 0; i < s.size(); ++i)
	{

		cout << " " << popCommand[i];
	}

	if (flag)
	{
		cout << '\n';
	}

	s.clear();
	return 0;
}

int main()
{

	int n;
	cin >> n;

	int e;
	int lastIndex = 0;
	for (int k = 0; k < n; ++k)
	{
		cin >> e;

		if (e != 0)
		{
			s.insert({e,k});
			continue;
		}

		if (s.size() <= 3)
		{
			if (k < n-1)
			{
				lessThan3(true);
			} else {
				lessThan3(false);
			}

			lastIndex = k+1;
			continue;
		}

		int index[3],l=0;
		for (auto ele:s)
		{
			if (l >= 3)
			{
				break;
			}

			index[l] = ele.second;
			l++;
		}

		for (int i = lastIndex; i <= index[0]; ++i)
		{
			cout << insertCommand[0] << '\n';
		}

		for (int i = index[0]+1; i <= index[1]; ++i)
		{
			cout << insertCommand[2] << '\n';
		}

		for (int i = index[1]+1; i < index[2]; ++i)
		{
			cout << insertCommand[3] << '\n';
		}

		for (int i = index[2]; i < k; ++i)
		{
			cout << insertCommand[1] << '\n';
		}

		cout << 3;

		for (int i = 0; i < 3; ++i)
		{
			cout << " " << popCommand[i];
		}

		if (k != n-1)
		{
			cout << '\n';
		}

		s.clear();
		lastIndex = k+1;
	}

	for (int i = 0; i < s.size(); ++i)
	{
		cout << insertCommand[0];

		if (i != s.size()-1)
		{
			cout << '\n';
		}
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

const string insertCommand[4] = {"pushStack","pushQueue","pushFront","pushBack"};
const string popCommand[4] = {"popStack","popQueue","popFront","popBack"};

set< pair<int,int>,greater< pair<int,int> > > s;

int lessThan3(bool flag)
{
	for (int i = 0; i < s.size(); ++i)
	{
		cout << insertCommand[i] << '\n';
	}

	cout << s.size();

	for (int i = 0; i < s.size(); ++i)
	{

		cout << " " << popCommand[i];
	}

	if (flag)
	{
		cout << '\n';
	}

	s.clear();
	return 0;
}

int main()
{

	int n;
	cin >> n;

	int e;
	int lastIndex = 0;
	for (int k = 0; k < n; ++k)
	{
		cin >> e;

		if (e != 0)
		{
			s.insert({e,k});
			continue;
		}

		if (s.size() <= 3)
		{
			if (k < n-1)
			{
				lessThan3(true);
			} else {
				lessThan3(false);
			}

			lastIndex = k+1;
			continue;
		}

		int index[3],l=0;
		for (auto ele:s)
		{
			if (l >= 3)
			{
				break;
			}

			index[l] = ele.second;
			l++;
		}

		sort(index,index+3);
		for (int i = lastIndex; i <= index[0]; ++i)
		{
			cout << insertCommand[0] << '\n';
		}

		for (int i = index[0]+1; i <= index[1]; ++i)
		{
			cout << insertCommand[2] << '\n';
		}

		for (int i = index[1]+1; i < index[2]; ++i)
		{
			cout << insertCommand[3] << '\n';
		}

		for (int i = index[2]; i < k; ++i)
		{
			cout << insertCommand[1] << '\n';
		}

		cout << 3;

		for (int i = 0; i < 3; ++i)
		{
			cout << " " << popCommand[i];
		}

		if (k != n-1)
		{
			cout << '\n';
		}

		s.clear();
		lastIndex = k+1;
	}

	for (int i = 0; i < s.size(); ++i)
	{
		cout << insertCommand[0];

		if (i != s.size()-1)
		{
			cout << '\n';
		}
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

const string insertCommand[4] = {"pushStack","pushQueue","pushFront","pushBack"};
const string popCommand[4] = {"popStack","popQueue","popFront","popBack"};

set<pair<int,int>> s;

int lessThan3(bool flag)
{
	for (int i = 0; i < s.size(); ++i)
	{
		cout << insertCommand[i] << '\n';
	}

	cout << s.size() << " ";

	for (int i = 0; i < s.size(); ++i)
	{
		cout << popCommand[i] << " ";
	}

	if (flag)
	{
		cout << '\n';
	}

	s.clear();
	return 0;
}

int main()
{

	int n;
	cin >> n;

	int e;
	int lastIndex = 0;
	for (int k = 0; k < n; ++k)
	{
		cin >> e;

		if (e != 0)
		{
			s.insert({e,k});
			continue;
		}

		if (s.size() <= 3)
		{
			if (k < n-1)
			{
				lessThan3(true);
			} else {
				lessThan3(false);
			}

			lastIndex = k+1;
			continue;
		}

		int index[3],l=0;
		for (auto ele:s)
		{
			if (l >= 3)
			{
				break;
			}

			index[l] = ele.second;
			l++;
		}

		for (int i = lastIndex; i <= index[0]; ++i)
		{
			cout << insertCommand[0] << '\n';
		}

		for (int i = index[0]+1; i <= index[1]; ++i)
		{
			cout << insertCommand[2] << '\n';
		}

		for (int i = index[1]+1; i < index[2]; ++i)
		{
			cout << insertCommand[3] << '\n';
		}

		for (int i = index[2]; i < k; ++i)
		{
			cout << insertCommand[1] << '\n';
		}

		cout << 3;

		for (int i = 0; i < 3; ++i)
		{
			cout << " " << popCommand[i];
		}

		if (k != n-1)
		{
			cout << '\n';
		}

		s.clear();
		lastIndex = k+1;
	}

	for (int i = 0; i < s.size(); ++i)
	{
		cout << insertCommand[0];

		if (i != s.size()-1)
		{
			cout << '\n';
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N=2e3+5;
int mk[5];
string s[5]={"@","Stack","Queue","Front","Back"};
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int Q,x;
	priority_queue<ii> q;
	cin>>Q;
	while(Q--)
	{
		cin>>x;
		if(x)
		{
			int mn=1e9,pos=-1;
			bool flag=false;
			for(int i=1;i<=4;i++)
			{
				if(!mk[i])
				{
					mk[i]=x;
					cout<<"push"<<s[i]<<"\n";
					flag=true;
					break;
				}
			}
			if(flag)
				continue;
			for(int i=1;i<=2;i++)
				if(mk[i]<=x)
				{
					mn[i]=x;
					pos=i;
					break;
				}
			if(pos==-1)
			{
				if(mk[3]>mk[4])
					pos=4;
				else
					pos=3;
			}
			cout<<"push"<<s[pos]<<"\n";
			mk[pos]=x;
		}
		else
		{
			int res=0;
			for(int i=1;i<=4;i++)
				if(mk[i])
					res++;
			if(mk[3]&&mk[4])
			{
				res--;
				if(mk[3]>=mk[4])
					mk[4]=0;
				else
					mk[3]=0;
			}
			cout<<res;
			for(int i=1;i<=4;i++)
			{
				if(mk[i])
				{
					mk[i]=0;
					cout<<" pop"<<s[i];
				}
			}
			cout<<"\n";
		}
	}

	return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<int,int> ii;
const int N=2e+5;
int mk[5];
vector<ii> v;
string s[4]={"Queue","Stack","Front","Back"};
bool cmp(ii a,ii b)
{
	return a.se<b.se;
}
void calc()
{
	int ans=0;
	vector<int> res(v.size());
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
		res[v[i].se]=3;
	for(int i=0;i<min(3,(int)v.size());i++)
		res[v[i].se]=i,ans++;
	sort(v.begin(),v.end(),cmp);
	for(int i=0;i<v.size();i++)
		cout<<"push"<<s[res[i]]<<"\n";
	cout<<ans;
	for(int i=0;i<ans;i++)
		cout<<" pop"<<s[i];
	cout<<"\n";
	res.clear();
}
int main()
{
	ios::sync_with_stdio(false);
	//cin.tie(0);
	int Q,x,id=0;
	cin>>Q;
	for(int i=0;i<Q;i++)
	{
		cin>>x;
		if(x)
			v.push_back(ii(x,id++));
		else
		{
			calc();
			id=0;
			v.clear();
		}
	}
	if(v.size())
		for(int i=0;i<v.size();i++)
			cout<<"pushQueue"<<"\n";
	return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<int,int> ii;
const int N=2e+5;
int mk[5];
vector<ii> v;
string s[4]={"Queue","Stack","Front","Back"};
bool cmp(ii a,ii b)
{
	return a.se<b.se;
}
void calc()
{
	int ans=0;
	vector<int> res(v.size());
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
		res[v[i].se]=4;
	for(int i=0;i<min(3,(int)v.size());i++)
		res[v[i].se]=i,ans++;
	sort(v.begin(),v.end(),cmp);
	for(int i=0;i<v.size();i++)
		cout<<"push"<<s[res[i]]<<"\n";
	cout<<ans;
	for(int i=0;i<ans;i++)
		cout<<" pop"<<s[i];
	cout<<"\n";
	res.clear();
}
int main()
{
	ios::sync_with_stdio(false);
	//cin.tie(0);
	int Q,x,id=0;
	cin>>Q;
	for(int i=0;i<Q;i++)
	{
		cin>>x;
		if(x)
			v.push_back(ii(x,id++));
		else
		{
			calc();
			id=0;
			v.clear();
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N=2e3+5;
int mk[5];
string s[5]={"@","Stack","Queue","Front","Back"};
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int Q,x;
	priority_queue<ii> q;
	cin>>Q;
	while(Q--)
	{
		cin>>x;
		if(x)
		{
			int mn=1e9,pos;
			bool flag=false;
			for(int i=1;i<=4;i++)
			{
				if(!mk[i])
				{
					mk[i]=x;
					cout<<"push"<<s[i]<<"\n";
					flag=true;
					break;
				}
				if(mn>=mk[i])
					mn=mk[i],pos=i;
			}
			if(flag)
				continue;
			if(mk[3]==mn)
				pos=3;
			if(mk[4]==mn)
				pos=4;
			cout<<"push"<<s[pos]<<"\n";
			mk[pos]=x;
		}
		else
		{
			int res=0;
			for(int i=1;i<=4;i++)
				if(mk[i])
					res++;
			if(mk[3]&&mk[4])
			{
				res--;
				if(mk[3]>=mk[4])
					mk[4]=0;
				else
					mk[3]=0;
			}
			cout<<res;
			for(int i=1;i<=4;i++)
			{
				if(mk[i])
				{
					mk[i]=0;
					cout<<" pop"<<s[i];
				}
			}
			cout<<"\n";
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N=2e3+5;
int mk[5];
string s[5]={"@","Stack","Queue","Front","Back"};
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int Q,x;
	priority_queue<ii> q;
	cin>>Q;
	while(Q--)
	{
		cin>>x;
		if(x)
		{
			int mn=1e9,pos;
			bool flag=false;
			for(int i=1;i<=4;i++)
			{
				if(!mk[i])
				{
					mk[i]=x;
					cout<<"push"<<s[i]<<"\n";
					flag=true;
					break;
				}
			}
			if(flag)
				continue;
			if(mk[3]>mk[4])
				pos=3;
			else
				pos=4;
			cout<<"push"<<s[pos]<<"\n";
			mk[pos]=x;
		}
		else
		{
			int res=0;
			for(int i=1;i<=4;i++)
				if(mk[i])
					res++;
			if(mk[3]&&mk[4])
			{
				res--;
				if(mk[3]>=mk[4])
					mk[4]=0;
				else
					mk[3]=0;
			}
			cout<<res;
			for(int i=1;i<=4;i++)
			{
				if(mk[i])
				{
					mk[i]=0;
					cout<<" pop"<<s[i];
				}
			}
			cout<<"\n";
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N=2e3+5;
int mk[5];
string s[5]={"@","Stack","Queue","Front","Back"};
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int Q,x;
	priority_queue<ii> q;
	cin>>Q;
	while(Q--)
	{
		cin>>x;
		if(x)
		{
			int mn=1e9,pos=-1;
			bool flag=false;
			for(int i=1;i<=4;i++)
			{
				if(!mk[i])
				{
					mk[i]=x;
					cout<<"push"<<s[i]<<"\n";
					flag=true;
					break;
				}
			}
			if(flag)
				continue;
			for(int i=1;i<=2;i++)
				if(mk[i]<=x)
				{
					mk[i]=x;
					pos=i;
					break;
				}
			if(pos==-1)
			{
				if(mk[3]>mk[4])
					pos=4;
				else
					pos=3;
			}
			cout<<"push"<<s[pos]<<"\n";
			mk[pos]=x;
		}
		else
		{
			int res=0;
			for(int i=1;i<=4;i++)
				if(mk[i])
					res++;
			if(mk[3]&&mk[4])
			{
				res--;
				if(mk[3]>=mk[4])
					mk[4]=0;
				else
					mk[3]=0;
			}
			cout<<res;
			for(int i=1;i<=4;i++)
			{
				if(mk[i])
				{
					mk[i]=0;
					cout<<" pop"<<s[i];
				}
			}
			cout<<"\n";
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N=2e3+5;
int mk[5];
string s[5]={"@","Stack","Queue","Front","Back"};
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int Q,x;
	priority_queue<ii> q;
	cin>>Q;
	while(Q--)
	{
		cin>>x;
		if(x)
		{
			int mn=1e9,pos;
			bool flag=false;
			for(int i=1;i<=4;i++)
			{
				if(!mk[i])
				{
					mk[i]=x;
					cout<<"push"<<s[i]<<"\n";
					flag=true;
					break;
				}
				if(mn>=mk[i])
					mn=mk[i],pos=i;
			}
			if(flag)
				continue;
			cout<<"push"<<s[pos]<<"\n";
			mk[pos]=x;
		}
		else
		{
			int res=0;
			for(int i=1;i<=4;i++)
				if(mk[i])
					res++;
			if(res==4)
			{
				res--;
				if(mk[3]>=mk[4])
					mk[4]=0;
				else
					mk[3]=0;
			}
			cout<<res;
			for(int i=1;i<=4;i++)
			{
				if(mk[i])
				{
					mk[i]=0;
					cout<<" pop"<<s[i];
				}
			}
			cout<<"\n";
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N=2e3+5;
int mk[5];
string s[5]={"@","Stack","Queue","Front","Back"};
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int Q,x;
	priority_queue<ii> q;
	cin>>Q;
	while(Q--)
	{
		cin>>x;
		if(x)
		{
			int mn=1e9,pos;
			bool flag=false;
			for(int i=1;i<=4;i++)
			{
				if(!mk[i])
				{
					mk[i]=x;
					cout<<"push"<<s[i]<<"\n";
					flag=true;
					break;
				}
				if(mn>=mk[i])
					mn=mk[i],pos=i;
			}
			if(flag)
				continue;
			cout<<"push"<<s[pos]<<"\n";
			mk[pos]=x;
		}
		else
		{
			int res=0;
			for(int i=1;i<=4;i++)
				if(mk[i])
					res++;
			cout<<res;
			for(int i=1;i<=4;i++)
			{
				if(mk[i])
				{
					mk[i]=0;
					cout<<" pop"<<s[i];
				}
			}
			cout<<"\n";
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N=2e3+5;
int mk[5];
string s[5]={"@","Stack","Queue","Front","Back"};
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int Q,x;
	priority_queue<ii> q;
	cin>>Q;
	while(Q--)
	{
		cin>>x;
		if(x)
		{
			int mn=1e9,pos;
			bool flag=false;
			for(int i=1;i<=4;i++)
			{
				if(!mk[i])
				{
					mk[i]=x;
					cout<<"push"<<s[i]<<"\n";
					flag=true;
					break;
				}
				if(mn>=mk[i])
					mn=mk[i],pos=i;
			}
			if(flag)
				continue;
			cout<<"push"<<s[pos]<<"\n";
			mk[pos]=x;
		}
		else
		{
			int res=0;
			for(int i=1;i<=4;i++)
				if(mk[i])
					res++;
			if(mk[3]&&mk[4])
			{
				res--;
				if(mk[3]>=mk[4])
					mk[4]=0;
				else
					mk[3]=0;
			}
			cout<<res;
			for(int i=1;i<=4;i++)
			{
				if(mk[i])
				{
					mk[i]=0;
					cout<<" pop"<<s[i];
				}
			}
			cout<<"\n";
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N=2e3+5;
int mk[5];
string s[5]={"@","Stack","Queue","Front","Back"};
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int Q,x;
	priority_queue<ii> q;
	cin>>Q;
	while(Q--)
	{
		cin>>x;
		if(x)
		{
			int mn=1e9,pos;
			bool flag=false;
			for(int i=1;i<=4;i++)
			{
				if(!mk[i])
				{
					mk[i]=x;
					cout<<"push"<<s[i]<<"\n";
					flag=true;
					break;
				}
				if(mn>=mk[i])
					mn=mk[i],pos=i;
			}
			if(flag)
				continue;
			cout<<"push"<<s[pos]<<"\n";
			mk[pos]=x;
		}
		else
		{
			int res=0;
			for(int i=1;i<=4;i++)
				if(mk[i])
					res++;
			cout<<res<<" ";
			for(int i=1;i<=4;i++)
			{
				if(mk[i])
				{
					mk[i]=0;
					cout<<"pop"<<s[i]<<" ";
				}
			}
			cout<<"\n";
		}
	}

	return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<int,int> ii;
const int N=2e+5;
int mk[5];
vector<ii> v;
string s[4]={"Queue","Stack","Front","Back"};
bool cmp(ii a,ii b)
{
	return a.se<b.se;
}
void calc()
{
	int ans=0;
	vector<int> res(v.size());
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
		res[v[i].se]=4;
	for(int i=0;i<min(3,(int)v.size());i++)
		res[v[i].se]=i,ans++;
	sort(v.begin(),v.end(),cmp);
	for(int i=0;i<v.size();i++)
		cout<<"push"<<s[res[i]]<<"\n";
	cout<<ans;
	for(int i=0;i<ans;i++)
		cout<<" pop"<<s[i];
	cout<<"\n";
	res.clear();
}
int main()
{
	ios::sync_with_stdio(false);
	//cin.tie(0);
	int Q,x,id=0;
	cin>>Q;
	for(int i=0;i<Q;i++)
	{
		cin>>x;
		if(x)
			v.push_back(ii(x,id++));
		else
		{
			calc();
			id=0;
			v.clear();
		}
	}
	if(v.size())
		for(int i=0;i<v.size();i++)
			cout<<"pushQueue"<<"\n";
	return 0;
}