#include <bits/stdc++.h>
using namespace std;
#define in(x) int x; cin>>x;
#define sin(s) string s; cin>>s;
#define ll long long
#define lin(x) ll x; cin>>x;
#define vi vector<int>
#define vll vector<ll>
#define si set<int>
#define pb push_back
#define re(i,n) for(ll i=0; i<n; i++)
#define pe(i,a,b) for(ll i=a; i<=b; i++)
#define rre(i,n) for(int i=n-1; i>-1; i--)
#define mp make_pair
#define pii pair<ll,ll>
#define endl "\n"
#define pi 3.1415926536
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define mod 1000000007
#define inf INT_MAX
#define ninf -INT_MAX
/////////////////////////////////////////////////////////////////////////////////

bool compare(const pair<pair<int, int>,int>&i, const pair<pair<int, int>,int>&j)
{
        return i.first.first<j.first.first;
}
/////////////////////////////////////////////////////////////////////////////////
//vi v;
int ncr(int n, int k)
{
        if(n<k)
                return 0;
        int C[n + 1][k + 1];
        int i, j;
        for (i = 0; i <= n; i++)
        {
                for (j = 0; j <= min(i, k); j++)
                {
                        if (j == 0 || j == i)
                                C[i][j] = 1;
                        else
                                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j])%mod;
                }
        }
        return C[n][k];
}
////////////////////////////////////////////////////////////////////////////
ll modpowIter(ll a, ll b, ll c)
{
        int ans=1;
        while(b != 0)
        {
                if(b%2 == 1)
                ans=(ans*a)%c;
                a=(a*a)%c;
                b /= 2;
        }
        return ans;
}
///////////////////////////////////////////////////////////////////////////////
string intobin(int n)
{
        string s="";
        if(n==0)
                s="0";
        while(n)
        {
                if(n%2)
                        s="1"+s;
                else
                        s="0"+s;
                n/=2;
        }
        return s;
}

////////////////////////////////////////////////////////////////////////////////
vll v;
int bintoin(string s)
{
        v.pb(1);
        re(i,101)
        {
                v.pb((v[v.size()-1]*2)%mod);
        }
        ll n=0;
        rre(i,s.length())
        {
                n=((n+(s[i]-'0')*v[s.length()-i-1])%mod)%mod;
                //cout<<v[s.length()-i-1]<<endl;
        }
        return n;
}
//////////////////////////////////////////////////////////////////////////////////
ll nc2(ll n, ll k)
{
        if(n<k)
                return 0;
        return (n*(n-1))/2;
}
///////////////////////////////////////////////////////////////////////////////////
bool prime[1000001];
void SieveOfEratosthenes(int n)
{
        memset(prime, true, sizeof(prime));
        for (int p=2; p*p<=n; p++)
        {
                if (prime[p] == true)
                {
                        for (int i=p*p; i<=n; i += p)
                        prime[i] = false;
                }
        }
        /*for (int p=2; p<=n; p++)
                if (prime[p])
                        v.pb(p);  */
}
////////////////////////////////////////////////////////////////////////////////////
ll p(ll a, ll b){
        long long x=1, y=a;
        while (b > 0)
        {
                if (b%2 == 1)
                {
                        x = (x*y) % mod;
                }
                y = (y*y) % mod;
                b /= 2;
        }
        return x % mod;
}

ll inv(ll a)
{
        return p(a, mod-2);
}
//////////////////////////////////////////////////////////////////////////////////////

class Deque
{
int  array[100001];
int  front;
int  rear;
int  size;
public :
Deque(int size) {
front = -1;
rear = 0;
this->size = size;
    }

    // Operations on Deque:
void  insertfront(int key);
void  insertrear(int key);
void  deletefront();
void  deleterear();
int  getFront();
int  getRear();

    // Check if Deque is full
bool  isFull(){
return ((front == 0 && rear == size-1)||front == rear+1);
    }
    // Check if Deque is empty
bool  isEmpty(){
return (front == -1);
    }
};

// Insert an element at front of the deque
void Deque::insertfront(int key)
{
if (isFull())  {
return;
    }

    // If queue is initially empty,set front=rear=0; start of deque
if (front == -1)  {
front = 0;
rear = 0;
    }
else if (front == 0)              // front is first position of queue
front = size - 1 ;
else // decrement front 1 position
front = front-1;

array[front] = key ;            // insert current element into Deque
}

// insert element at the rear end of deque
void Deque ::insertrear(int key)
{
if (isFull()) {
return;
    }

    //  If queue is initially empty,set front=rear=0; start of deque
if (front == -1) {
front = 0;
rear = 0;
    }
else if (rear == size-1)               // rear is at last position of queue
rear = 0;
else                            // increment rear by 1 position
rear = rear+1;

array[rear] = key ;         // insert current element into Deque
}

// Delete element at front of Deque
void Deque ::deletefront()
{
if (isEmpty())
   {

return ;
    }

    // Deque has only one element
 if (front == rear)
    {
front = -1;
rear = -1;
    }
else
        // back to initial position
if (front == size -1)
front = 0;

else // remove current front value from Deque;increment front by 1
front = front+1;
}

// Delete element at rear end of Deque
void Deque::deleterear()
{
if (isEmpty())
    {
        return ;
    }

    // Deque has only one element
if (front == rear)
    {
front = -1;
rear = -1;
    }
else if (rear == 0)
rear = size-1;
else
rear = rear-1;
}
// retrieve front element of Deque
int Deque::getFront()
{
if (isEmpty())
{
return -1 ;
}
return array[front];
}

// retrieve rear element of Deque
int Deque::getRear()
{
if(isEmpty() || rear < 0)
{
        return -1 ;
}
return array[rear];
}

int main()
{
        in(n)
        Deque dq(n);
        queue <int> q;
        stack <int> s;
        int arr[n];
        re(i,n)
        cin>>arr[i];
        int i=0;
        vi v;
        while(i<n-2)
        {
                if(!arr[i])
                {
                        if(v.size()==0)
                                cout<<"0"<<endl;
                        else if(v.size()==1)
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                //s.pop();
                        }
                        else if(v.size()==2)
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                //s.pop();
                                //q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue popFront";
                                //s.pop();
                                //q.pop();
                                //dq.deletefront();
                        }
                        i++;
                }
                else
                {
                        v.clear();
                        while(i<n && arr[i])
                        {
                                v.pb(arr[i]);
                                i++;
                        }
                        sort(v.begin(),v.end(),greater <int>());
                        if(v.size()==1)
                        {
                                //s.push(v[0]);
                                cout<<"pushStack"<<endl;
                        }
                        else if(v.size()==2)
                        {
                                //s.push(v[0]);
                                //q.push(v[1]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                        }
                        else
                        {
                                //s.push(v[0]);
                                //q.push(v[1]);
                                //dq.insertfront(v[2]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                                cout<<"pushFront"<<endl;
                                for(int j=3;j<v.size();j++)
                                {
                                        //dq.insertrear(v[j]);
                                        cout<<"pushBack"<<endl;

                                }
                        }
                }
        }
        if(i<n)
        {
                while(i<n)
                {
                if(!arr[i])
                {
                        if(v.size()==0)
                                cout<<"0"<<endl;
                        else if(v.size()==1)
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                //s.pop();
                        }
                        else if(v.size()==2)
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                //s.pop();
                                //q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue popFront";
                                //s.pop();
                                //q.pop();
                                //dq.deletefront();
                        }
                }
                else
                {
                        v.clear();
                        while(i<n && arr[i])
                        {
                                v.pb(arr[i]);
                                i++;
                        }
                        i++;
                        sort(v.begin(),v.end(),greater <int>());
                        if(v.size()==1)
                        {
                                //s.push(v[0]);
                                cout<<"pushStack"<<endl;
                        }
                        else if(v.size()==2)
                        {
                                //s.push(v[0]);
                                //q.push(v[1]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                        }
                        else
                        {
                                //s.push(v[0]);
                                //q.push(v[1]);
                                //dq.insertfront(v[2]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                                cout<<"pushFront"<<endl;
                                for(int j=3;j<v.size();j++)
                                {
                                        //dq.insertrear(v[j]);
                                        cout<<"pushBack"<<endl;

                                }
                        }
                }
                i++;
                }
        }
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define in(x) int x; cin>>x;
#define sin(s) string s; cin>>s;
#define ll long long
#define lin(x) ll x; cin>>x;
#define vi vector<int>
#define vll vector<ll>
#define si set<int>
#define pb push_back
#define re(i,n) for(ll i=0; i<n; i++)
#define pe(i,a,b) for(ll i=a; i<=b; i++)
#define rre(i,n) for(int i=n-1; i>-1; i--)
#define mp make_pair
#define pii pair<ll,ll>
#define endl "\n"
#define pi 3.1415926536
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define mod 1000000007
#define inf INT_MAX
#define ninf -INT_MAX
/////////////////////////////////////////////////////////////////////////////////

bool compare(const pair<pair<int, int>,int>&i, const pair<pair<int, int>,int>&j)
{
        return i.first.first<j.first.first;
}
/////////////////////////////////////////////////////////////////////////////////
//vi v;
int ncr(int n, int k)
{
        if(n<k)
                return 0;
        int C[n + 1][k + 1];
        int i, j;
        for (i = 0; i <= n; i++)
        {
                for (j = 0; j <= min(i, k); j++)
                {
                        if (j == 0 || j == i)
                                C[i][j] = 1;
                        else
                                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j])%mod;
                }
        }
        return C[n][k];
}
////////////////////////////////////////////////////////////////////////////
ll modpowIter(ll a, ll b, ll c)
{
        int ans=1;
        while(b != 0)
        {
                if(b%2 == 1)
                ans=(ans*a)%c;
                a=(a*a)%c;
                b /= 2;
        }
        return ans;
}
///////////////////////////////////////////////////////////////////////////////
string intobin(int n)
{
        string s="";
        if(n==0)
                s="0";
        while(n)
        {
                if(n%2)
                        s="1"+s;
                else
                        s="0"+s;
                n/=2;
        }
        return s;
}

////////////////////////////////////////////////////////////////////////////////
vll v;
int bintoin(string s)
{
        v.pb(1);
        re(i,101)
        {
                v.pb((v[v.size()-1]*2)%mod);
        }
        ll n=0;
        rre(i,s.length())
        {
                n=((n+(s[i]-'0')*v[s.length()-i-1])%mod)%mod;
                //cout<<v[s.length()-i-1]<<endl;
        }
        return n;
}
//////////////////////////////////////////////////////////////////////////////////
ll nc2(ll n, ll k)
{
        if(n<k)
                return 0;
        return (n*(n-1))/2;
}
///////////////////////////////////////////////////////////////////////////////////
bool prime[1000001];
void SieveOfEratosthenes(int n)
{
        memset(prime, true, sizeof(prime));
        for (int p=2; p*p<=n; p++)
        {
                if (prime[p] == true)
                {
                        for (int i=p*p; i<=n; i += p)
                        prime[i] = false;
                }
        }
        /*for (int p=2; p<=n; p++)
                if (prime[p])
                        v.pb(p);  */
}
////////////////////////////////////////////////////////////////////////////////////
ll p(ll a, ll b){
        long long x=1, y=a;
        while (b > 0)
        {
                if (b%2 == 1)
                {
                        x = (x*y) % mod;
                }
                y = (y*y) % mod;
                b /= 2;
        }
        return x % mod;
}

ll inv(ll a)
{
        return p(a, mod-2);
}
//////////////////////////////////////////////////////////////////////////////////////

class Deque
{
int  array[100001];
int  front;
int  rear;
int  size;
public :
Deque(int size) {
front = -1;
rear = 0;
this->size = size;
    }

    // Operations on Deque:
void  insertfront(int key);
void  insertrear(int key);
void  deletefront();
void  deleterear();
int  getFront();
int  getRear();

    // Check if Deque is full
bool  isFull(){
return ((front == 0 && rear == size-1)||front == rear+1);
    }
    // Check if Deque is empty
bool  isEmpty(){
return (front == -1);
    }
};

// Insert an element at front of the deque
void Deque::insertfront(int key)
{
if (isFull())  {
return;
    }

    // If queue is initially empty,set front=rear=0; start of deque
if (front == -1)  {
front = 0;
rear = 0;
    }
else if (front == 0)              // front is first position of queue
front = size - 1 ;
else // decrement front 1 position
front = front-1;

array[front] = key ;            // insert current element into Deque
}

// insert element at the rear end of deque
void Deque ::insertrear(int key)
{
if (isFull()) {
return;
    }

    //  If queue is initially empty,set front=rear=0; start of deque
if (front == -1) {
front = 0;
rear = 0;
    }
else if (rear == size-1)               // rear is at last position of queue
rear = 0;
else                            // increment rear by 1 position
rear = rear+1;

array[rear] = key ;         // insert current element into Deque
}

// Delete element at front of Deque
void Deque ::deletefront()
{
if (isEmpty())
   {

return ;
    }

    // Deque has only one element
 if (front == rear)
    {
front = -1;
rear = -1;
    }
else
        // back to initial position
if (front == size -1)
front = 0;

else // remove current front value from Deque;increment front by 1
front = front+1;
}

// Delete element at rear end of Deque
void Deque::deleterear()
{
if (isEmpty())
    {
        return ;
    }

    // Deque has only one element
if (front == rear)
    {
front = -1;
rear = -1;
    }
else if (rear == 0)
rear = size-1;
else
rear = rear-1;
}
// retrieve front element of Deque
int Deque::getFront()
{
if (isEmpty())
{
return -1 ;
}
return array[front];
}

// retrieve rear element of Deque
int Deque::getRear()
{
if(isEmpty() || rear < 0)
{
        return -1 ;
}
return array[rear];
}

int main()
{
        in(n)
        Deque dq(n);
        queue <int> q;
        stack <int> s;
        int arr[n];
        re(i,n)
        cin>>arr[i];
        int i=0;
        while(i<n-2)
        {
                if(!arr[i])
                {
                        if(s.size()==0 && q.size()==0 && dq.isEmpty())
                                cout<<"0"<<endl;
                        else if(s.size() && q.size()==0 && dq.isEmpty())
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                s.pop();
                        }
                        else if(s.size() && q.size() && dq.isEmpty())
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                s.pop();
                                q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue popFront";
                                s.pop();
                                q.pop();
                                dq.deletefront();
                        }
                        i++;
                }
                else
                {
                        vi v;
                        while(i<n && arr[i])
                        {
                                v.pb(arr[i]);
                                i++;
                        }
                        sort(v.begin(),v.end(),greater <int>());
                        if(v.size()==1)
                        {
                                s.push(v[0]);
                                cout<<"pushStack"<<endl;
                        }
                        else if(v.size()==2)
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                        }
                        else
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                dq.insertfront(v[2]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                                cout<<"pushFront"<<endl;
                                for(int j=3;j<v.size();j++)
                                {
                                        dq.insertrear(v[j]);
                                        cout<<"pushBack"<<endl;

                                }
                        }
                }
        }
        if(i<n)
        {
                while(i<n)
                {
                if(!arr[i])
                {
                        if(s.size()==0 && q.size()==0 && dq.isEmpty())
                                cout<<"0"<<endl;
                        else if(s.size() && q.size()==0 && dq.isEmpty())
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                s.pop();
                        }
                        else if(s.size() && q.size() && dq.isEmpty())
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                s.pop();
                                q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue popFront";
                                s.pop();
                                q.pop();
                                dq.deletefront();
                        }
                }
                else
                {
                        vi v;
                        while(i<n && arr[i])
                        {
                                v.pb(arr[i]);
                                i++;
                        }
                        i++;
                        sort(v.begin(),v.end(),greater <int>());
                        if(v.size()==1)
                        {
                                s.push(v[0]);
                                cout<<"pushStack"<<endl;
                        }
                        else if(v.size()==2)
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                        }
                        else
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                dq.insertfront(v[2]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                                cout<<"pushFront"<<endl;
                                for(int j=3;j<v.size();j++)
                                {
                                        dq.insertrear(v[j]);
                                        cout<<"pushBack"<<endl;

                                }
                        }
                }
                i++;
                }
        }
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define in(x) int x; cin>>x;
#define sin(s) string s; cin>>s;
#define ll long long
#define lin(x) ll x; cin>>x;
#define vi vector<int>
#define vll vector<ll>
#define si set<int>
#define pb push_back
#define re(i,n) for(ll i=0; i<n; i++)
#define pe(i,a,b) for(ll i=a; i<=b; i++)
#define rre(i,n) for(int i=n-1; i>-1; i--)
#define mp make_pair
#define pii pair<ll,ll>
#define endl "\n"
#define pi 3.1415926536
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define mod 1000000007
#define inf INT_MAX
#define ninf -INT_MAX
/////////////////////////////////////////////////////////////////////////////////

bool compare(const pair<pair<int, int>,int>&i, const pair<pair<int, int>,int>&j)
{
        return i.first.first<j.first.first;
}
/////////////////////////////////////////////////////////////////////////////////
//vi v;
int ncr(int n, int k)
{
        if(n<k)
                return 0;
        int C[n + 1][k + 1];
        int i, j;
        for (i = 0; i <= n; i++)
        {
                for (j = 0; j <= min(i, k); j++)
                {
                        if (j == 0 || j == i)
                                C[i][j] = 1;
                        else
                                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j])%mod;
                }
        }
        return C[n][k];
}
////////////////////////////////////////////////////////////////////////////
ll modpowIter(ll a, ll b, ll c)
{
        int ans=1;
        while(b != 0)
        {
                if(b%2 == 1)
                ans=(ans*a)%c;
                a=(a*a)%c;
                b /= 2;
        }
        return ans;
}
///////////////////////////////////////////////////////////////////////////////
string intobin(int n)
{
        string s="";
        if(n==0)
                s="0";
        while(n)
        {
                if(n%2)
                        s="1"+s;
                else
                        s="0"+s;
                n/=2;
        }
        return s;
}

////////////////////////////////////////////////////////////////////////////////
vll v;
int bintoin(string s)
{
        v.pb(1);
        re(i,101)
        {
                v.pb((v[v.size()-1]*2)%mod);
        }
        ll n=0;
        rre(i,s.length())
        {
                n=((n+(s[i]-'0')*v[s.length()-i-1])%mod)%mod;
                //cout<<v[s.length()-i-1]<<endl;
        }
        return n;
}
//////////////////////////////////////////////////////////////////////////////////
ll nc2(ll n, ll k)
{
        if(n<k)
                return 0;
        return (n*(n-1))/2;
}
///////////////////////////////////////////////////////////////////////////////////
bool prime[1000001];
void SieveOfEratosthenes(int n)
{
        memset(prime, true, sizeof(prime));
        for (int p=2; p*p<=n; p++)
        {
                if (prime[p] == true)
                {
                        for (int i=p*p; i<=n; i += p)
                        prime[i] = false;
                }
        }
        /*for (int p=2; p<=n; p++)
                if (prime[p])
                        v.pb(p);  */
}
////////////////////////////////////////////////////////////////////////////////////
ll p(ll a, ll b){
        long long x=1, y=a;
        while (b > 0)
        {
                if (b%2 == 1)
                {
                        x = (x*y) % mod;
                }
                y = (y*y) % mod;
                b /= 2;
        }
        return x % mod;
}

ll inv(ll a)
{
        return p(a, mod-2);
}
//////////////////////////////////////////////////////////////////////////////////////

class Deque
{
int  array[100001];
int  front;
int  rear;
int  size;
public :
Deque(int size) {
front = -1;
rear = 0;
this->size = size;
    }

    // Operations on Deque:
void  insertfront(int key);
void  insertrear(int key);
void  deletefront();
void  deleterear();
int  getFront();
int  getRear();

    // Check if Deque is full
bool  isFull(){
return ((front == 0 && rear == size-1)||front == rear+1);
    }
    // Check if Deque is empty
bool  isEmpty(){
return (front == -1);
    }
};

// Insert an element at front of the deque
void Deque::insertfront(int key)
{
if (isFull())  {
return;
    }

    // If queue is initially empty,set front=rear=0; start of deque
if (front == -1)  {
front = 0;
rear = 0;
    }
else if (front == 0)              // front is first position of queue
front = size - 1 ;
else // decrement front 1 position
front = front-1;

array[front] = key ;            // insert current element into Deque
}

// insert element at the rear end of deque
void Deque ::insertrear(int key)
{
if (isFull()) {
return;
    }

    //  If queue is initially empty,set front=rear=0; start of deque
if (front == -1) {
front = 0;
rear = 0;
    }
else if (rear == size-1)               // rear is at last position of queue
rear = 0;
else                            // increment rear by 1 position
rear = rear+1;

array[rear] = key ;         // insert current element into Deque
}

// Delete element at front of Deque
void Deque ::deletefront()
{
if (isEmpty())
   {

return ;
    }

    // Deque has only one element
 if (front == rear)
    {
front = -1;
rear = -1;
    }
else
        // back to initial position
if (front == size -1)
front = 0;

else // remove current front value from Deque;increment front by 1
front = front+1;
}

// Delete element at rear end of Deque
void Deque::deleterear()
{
if (isEmpty())
    {
        return ;
    }

    // Deque has only one element
if (front == rear)
    {
front = -1;
rear = -1;
    }
else if (rear == 0)
rear = size-1;
else
rear = rear-1;
}
// retrieve front element of Deque
int Deque::getFront()
{
if (isEmpty())
{
return -1 ;
}
return array[front];
}

// retrieve rear element of Deque
int Deque::getRear()
{
if(isEmpty() || rear < 0)
{
        return -1 ;
}
return array[rear];
}

int main()
{
        in(n)
        Deque dq(n);
        queue <int> q;
        stack <int> s;
        int arr[n];
        re(i,n)
        cin>>arr[i];
        int i=0;
        while(i<n-2)
        {
                if(!arr[i])
                {
                        if(s.size()==0 && q.size()==0 && dq.isEmpty())
                                cout<<"0"<<endl;
                        else if(s.size() && q.size()==0 && dq.isEmpty())
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                s.pop();
                        }
                        else if(s.size() && q.size() && dq.isEmpty())
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                s.pop();
                                q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue ";
                                s.pop();
                                q.pop();
                                if(dq.getRear()>dq.getFront())
                                {
                                        cout<<"popBack"<<endl;
                                        dq.deleterear();
                                }
                                else
                                {
                                        cout<<"popFront"<<endl;
                                        dq.deletefront();
                                }
                        }
                        i++;
                }
                else
                {
                        vi v;
                        while(i<n && arr[i])
                        {
                                v.pb(arr[i]);
                                i++;
                        }
                        sort(v.begin(),v.end(),greater <int>());
                        if(v.size()==1)
                        {
                                s.push(v[0]);
                                cout<<"pushStack"<<endl;
                        }
                        else if(v.size()==2)
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                        }
                        else
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                //dq.insertfront(v[2]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                                for(int j=v.size()-1;j>1;j--)
                                {
                                        if(v[j]<=dq.getFront() && v[j]<=dq.getRear())
                                        {
                                                if(dq.getFront()-v[j]<dq.getRear()-v[j])
                                                {
                                                        dq.insertfront(v[j]);
                                                        cout<<"pushFront"<<endl;
                                                }
                                                else
                                                {
                                                        dq.insertrear(v[j]);
                                                        cout<<"pushBack"<<endl;
                                                }
                                        }
                                        else if(v[j]>=dq.getFront() && v[j]<=dq.getRear())
                                        {
                                                dq.insertfront(v[j]);
                                                cout<<"pushFront"<<endl;
                                        }
                                        else if(v[j]<=dq.getFront() && v[j]>=dq.getRear())
                                        {
                                                dq.insertrear(v[j]);
                                                cout<<"pushBack"<<endl;
                                        }
                                        else
                                        {
                                                if(dq.getFront()-v[j]>dq.getRear()-v[j])
                                                {
                                                        dq.insertfront(v[j]);
                                                        cout<<"pushFront"<<endl;
                                                }
                                                else
                                                {
                                                        dq.insertrear(v[j]);
                                                        cout<<"pushBack"<<endl;
                                                }
                                        }
                                }
                        }
                }
        }
        if(i<n)
        {
                while(i<n)
                {
                if(!arr[i])
                {
                        if(s.size()==0 && q.size()==0 && dq.isEmpty())
                                cout<<"0"<<endl;
                        else if(s.size() && q.size()==0 && dq.isEmpty())
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                s.pop();
                        }
                        else if(s.size() && q.size() && dq.isEmpty())
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                s.pop();
                                q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue ";
                                s.pop();
                                q.pop();
                                if(dq.getRear()>dq.getFront())
                                {
                                        cout<<"popBack"<<endl;
                                        dq.deleterear();
                                }
                                else
                                {
                                        cout<<"popFront"<<endl;
                                        dq.deletefront();
                                }
                        }
                }
                else
                {
                        vi v;
                        while(i<n && arr[i])
                        {
                                v.pb(arr[i]);
                                i++;
                        }
                        i++;
                        sort(v.begin(),v.end(),greater <int>());
                        if(v.size()==1)
                        {
                                s.push(v[0]);
                                cout<<"pushStack"<<endl;
                        }
                        else if(v.size()==2)
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                        }
                        else
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                //dq.insertfront(v[2]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                                for(int j=v.size()-1;j>1;j--)
                                {
                                        if(v[j]<=dq.getFront() && v[j]<=dq.getRear())
                                        {
                                                if(dq.getFront()-v[j]<dq.getRear()-v[j])
                                                {
                                                        dq.insertfront(v[j]);
                                                        cout<<"pushFront"<<endl;
                                                }
                                                else
                                                {
                                                        dq.insertrear(v[j]);
                                                        cout<<"pushBack"<<endl;
                                                }
                                        }
                                        else if(v[j]>=dq.getFront() && v[j]<=dq.getRear())
                                        {
                                                dq.insertfront(v[j]);
                                                cout<<"pushFront"<<endl;
                                        }
                                        else if(v[j]<=dq.getFront() && v[j]>=dq.getRear())
                                        {
                                                dq.insertrear(v[j]);
                                                cout<<"pushBack"<<endl;
                                        }
                                        else
                                        {
                                                if(dq.getFront()-v[j]>dq.getRear()-v[j])
                                                {
                                                        dq.insertfront(v[j]);
                                                        cout<<"pushFront"<<endl;
                                                }
                                                else
                                                {
                                                        dq.insertrear(v[j]);
                                                        cout<<"pushBack"<<endl;
                                                }
                                        }
                                }
                        }
                }
                i++;
                }
        }
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define in(x) int x; cin>>x;
#define sin(s) string s; cin>>s;
#define ll long long
#define lin(x) ll x; cin>>x;
#define vi vector<int>
#define vll vector<ll>
#define si set<int>
#define pb push_back
#define re(i,n) for(ll i=0; i<n; i++)
#define pe(i,a,b) for(ll i=a; i<=b; i++)
#define rre(i,n) for(int i=n-1; i>-1; i--)
#define mp make_pair
#define pii pair<ll,ll>
#define endl "\n"
#define pi 3.1415926536
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define mod 1000000007
#define inf INT_MAX
#define ninf -INT_MAX
/////////////////////////////////////////////////////////////////////////////////

bool compare(const pair<pair<int, int>,int>&i, const pair<pair<int, int>,int>&j)
{
        return i.first.first<j.first.first;
}
/////////////////////////////////////////////////////////////////////////////////
//vi v;
int ncr(int n, int k)
{
        if(n<k)
                return 0;
        int C[n + 1][k + 1];
        int i, j;
        for (i = 0; i <= n; i++)
        {
                for (j = 0; j <= min(i, k); j++)
                {
                        if (j == 0 || j == i)
                                C[i][j] = 1;
                        else
                                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j])%mod;
                }
        }
        return C[n][k];
}
////////////////////////////////////////////////////////////////////////////
ll modpowIter(ll a, ll b, ll c)
{
        int ans=1;
        while(b != 0)
        {
                if(b%2 == 1)
                ans=(ans*a)%c;
                a=(a*a)%c;
                b /= 2;
        }
        return ans;
}
///////////////////////////////////////////////////////////////////////////////
string intobin(int n)
{
        string s="";
        if(n==0)
                s="0";
        while(n)
        {
                if(n%2)
                        s="1"+s;
                else
                        s="0"+s;
                n/=2;
        }
        return s;
}

////////////////////////////////////////////////////////////////////////////////
vll v;
int bintoin(string s)
{
        v.pb(1);
        re(i,101)
        {
                v.pb((v[v.size()-1]*2)%mod);
        }
        ll n=0;
        rre(i,s.length())
        {
                n=((n+(s[i]-'0')*v[s.length()-i-1])%mod)%mod;
                //cout<<v[s.length()-i-1]<<endl;
        }
        return n;
}
//////////////////////////////////////////////////////////////////////////////////
ll nc2(ll n, ll k)
{
        if(n<k)
                return 0;
        return (n*(n-1))/2;
}
///////////////////////////////////////////////////////////////////////////////////
bool prime[1000001];
void SieveOfEratosthenes(int n)
{
        memset(prime, true, sizeof(prime));
        for (int p=2; p*p<=n; p++)
        {
                if (prime[p] == true)
                {
                        for (int i=p*p; i<=n; i += p)
                        prime[i] = false;
                }
        }
        /*for (int p=2; p<=n; p++)
                if (prime[p])
                        v.pb(p);  */
}
////////////////////////////////////////////////////////////////////////////////////
ll p(ll a, ll b){
        long long x=1, y=a;
        while (b > 0)
        {
                if (b%2 == 1)
                {
                        x = (x*y) % mod;
                }
                y = (y*y) % mod;
                b /= 2;
        }
        return x % mod;
}

ll inv(ll a)
{
        return p(a, mod-2);
}
//////////////////////////////////////////////////////////////////////////////////////

class Deque
{
int  array[100001];
int  front;
int  rear;
int  size;
public :
Deque(int size) {
front = -1;
rear = 0;
this->size = size;
    }

    // Operations on Deque:
void  insertfront(int key);
void  insertrear(int key);
void  deletefront();
void  deleterear();
int  getFront();
int  getRear();

    // Check if Deque is full
bool  isFull(){
return ((front == 0 && rear == size-1)||front == rear+1);
    }
    // Check if Deque is empty
bool  isEmpty(){
return (front == -1);
    }
};

// Insert an element at front of the deque
void Deque::insertfront(int key)
{
if (isFull())  {
return;
    }

    // If queue is initially empty,set front=rear=0; start of deque
if (front == -1)  {
front = 0;
rear = 0;
    }
else if (front == 0)              // front is first position of queue
front = size - 1 ;
else // decrement front 1 position
front = front-1;

array[front] = key ;            // insert current element into Deque
}

// insert element at the rear end of deque
void Deque ::insertrear(int key)
{
if (isFull()) {
return;
    }

    //  If queue is initially empty,set front=rear=0; start of deque
if (front == -1) {
front = 0;
rear = 0;
    }
else if (rear == size-1)               // rear is at last position of queue
rear = 0;
else                            // increment rear by 1 position
rear = rear+1;

array[rear] = key ;         // insert current element into Deque
}

// Delete element at front of Deque
void Deque ::deletefront()
{
if (isEmpty())
   {

return ;
    }

    // Deque has only one element
 if (front == rear)
    {
front = -1;
rear = -1;
    }
else
        // back to initial position
if (front == size -1)
front = 0;

else // remove current front value from Deque;increment front by 1
front = front+1;
}

// Delete element at rear end of Deque
void Deque::deleterear()
{
if (isEmpty())
    {
        return ;
    }

    // Deque has only one element
if (front == rear)
    {
front = -1;
rear = -1;
    }
else if (rear == 0)
rear = size-1;
else
rear = rear-1;
}
// retrieve front element of Deque
int Deque::getFront()
{
if (isEmpty())
{
return -1 ;
}
return array[front];
}

// retrieve rear element of Deque
int Deque::getRear()
{
if(isEmpty() || rear < 0)
{
        return -1 ;
}
return array[rear];
}

int main()
{
        in(n)
        Deque dq(n);
        queue <int> q;
        stack <int> s;
        int arr[n];
        re(i,n)
        cin>>arr[i];
        int i=0;
        while(i<n-2)
        {
                if(!arr[i])
                {
                        if(s.size()==0 && q.size()==0 && dq.isEmpty())
                                cout<<"0"<<endl;
                        else if(s.size() && q.size()==0 && dq.isEmpty())
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                s.pop();
                        }
                        else if(s.size() && q.size() && dq.isEmpty())
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                s.pop();
                                q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue popFront";
                                s.pop();
                                q.pop();
                                dq.deletefront();
                        }
                        i++;
                }
                else
                {
                        vi v;
                        while(i<n && arr[i])
                        {
                                v.pb(arr[i]);
                                i++;
                        }
                        sort(v.begin(),v.end(),greater <int>());
                        if(v.size()==1)
                        {
                                s.push(v[0]);
                                cout<<"pushStack"<<endl;
                        }
                        else if(v.size()==2)
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                        }
                        else
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                dq.insertfront(v[2]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                                cout<<"pushFront"<<endl;
                                for(int j=v.size()-1;j>2;j--)
                                {
                                        dq.insertrear(v[j]);
                                        cout<<"pushBack"<<endl;

                                }
                        }
                }
        }
        if(i<n)
        {
                while(i<n)
                {
                if(!arr[i])
                {
                        if(s.size()==0 && q.size()==0 && dq.isEmpty())
                                cout<<"0"<<endl;
                        else if(s.size() && q.size()==0 && dq.isEmpty())
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                s.pop();
                        }
                        else if(s.size() && q.size() && dq.isEmpty())
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                s.pop();
                                q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue popFront";
                                s.pop();
                                q.pop();
                                dq.deletefront();
                        }
                }
                else
                {
                        vi v;
                        while(i<n && arr[i])
                        {
                                v.pb(arr[i]);
                                i++;
                        }
                        i++;
                        sort(v.begin(),v.end(),greater <int>());
                        if(v.size()==1)
                        {
                                s.push(v[0]);
                                cout<<"pushStack"<<endl;
                        }
                        else if(v.size()==2)
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                        }
                        else
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                dq.insertfront(v[2]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                                cout<<"pushFront"<<endl;
                                for(int j=v.size()-1;j>2;j--)
                                {
                                        dq.insertrear(v[j]);
                                        cout<<"pushBack"<<endl;

                                }
                        }
                }
                i++;
                }
        }
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define in(x) int x; cin>>x;
#define sin(s) string s; cin>>s;
#define ll long long
#define lin(x) ll x; cin>>x;
#define vi vector<int>
#define vll vector<ll>
#define si set<int>
#define pb push_back
#define re(i,n) for(ll i=0; i<n; i++)
#define pe(i,a,b) for(ll i=a; i<=b; i++)
#define rre(i,n) for(int i=n-1; i>-1; i--)
#define mp make_pair
#define pii pair<ll,ll>
#define endl "\n"
#define pi 3.1415926536
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define mod 1000000007
#define inf INT_MAX
#define ninf -INT_MAX
/////////////////////////////////////////////////////////////////////////////////

bool compare(const pair<pair<int, int>,int>&i, const pair<pair<int, int>,int>&j)
{
        return i.first.first<j.first.first;
}
/////////////////////////////////////////////////////////////////////////////////
//vi v;
int ncr(int n, int k)
{
        if(n<k)
                return 0;
        int C[n + 1][k + 1];
        int i, j;
        for (i = 0; i <= n; i++)
        {
                for (j = 0; j <= min(i, k); j++)
                {
                        if (j == 0 || j == i)
                                C[i][j] = 1;
                        else
                                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j])%mod;
                }
        }
        return C[n][k];
}
////////////////////////////////////////////////////////////////////////////
ll modpowIter(ll a, ll b, ll c)
{
        int ans=1;
        while(b != 0)
        {
                if(b%2 == 1)
                ans=(ans*a)%c;
                a=(a*a)%c;
                b /= 2;
        }
        return ans;
}
///////////////////////////////////////////////////////////////////////////////
string intobin(int n)
{
        string s="";
        if(n==0)
                s="0";
        while(n)
        {
                if(n%2)
                        s="1"+s;
                else
                        s="0"+s;
                n/=2;
        }
        return s;
}

////////////////////////////////////////////////////////////////////////////////
vll v;
int bintoin(string s)
{
        v.pb(1);
        re(i,101)
        {
                v.pb((v[v.size()-1]*2)%mod);
        }
        ll n=0;
        rre(i,s.length())
        {
                n=((n+(s[i]-'0')*v[s.length()-i-1])%mod)%mod;
                //cout<<v[s.length()-i-1]<<endl;
        }
        return n;
}
//////////////////////////////////////////////////////////////////////////////////
ll nc2(ll n, ll k)
{
        if(n<k)
                return 0;
        return (n*(n-1))/2;
}
///////////////////////////////////////////////////////////////////////////////////
bool prime[1000001];
void SieveOfEratosthenes(int n)
{
        memset(prime, true, sizeof(prime));
        for (int p=2; p*p<=n; p++)
        {
                if (prime[p] == true)
                {
                        for (int i=p*p; i<=n; i += p)
                        prime[i] = false;
                }
        }
        /*for (int p=2; p<=n; p++)
                if (prime[p])
                        v.pb(p);  */
}
////////////////////////////////////////////////////////////////////////////////////
ll p(ll a, ll b){
        long long x=1, y=a;
        while (b > 0)
        {
                if (b%2 == 1)
                {
                        x = (x*y) % mod;
                }
                y = (y*y) % mod;
                b /= 2;
        }
        return x % mod;
}

ll inv(ll a)
{
        return p(a, mod-2);
}
//////////////////////////////////////////////////////////////////////////////////////

class Deque
{
int  array[100001];
int  front;
int  rear;
int  size;
public :
Deque(int size) {
front = -1;
rear = 0;
this->size = size;
    }

    // Operations on Deque:
void  insertfront(int key);
void  insertrear(int key);
void  deletefront();
void  deleterear();
int  getFront();
int  getRear();

    // Check if Deque is full
bool  isFull(){
return ((front == 0 && rear == size-1)||front == rear+1);
    }
    // Check if Deque is empty
bool  isEmpty(){
return (front == -1);
    }
};

// Insert an element at front of the deque
void Deque::insertfront(int key)
{
if (isFull())  {
return;
    }

    // If queue is initially empty,set front=rear=0; start of deque
if (front == -1)  {
front = 0;
rear = 0;
    }
else if (front == 0)              // front is first position of queue
front = size - 1 ;
else // decrement front 1 position
front = front-1;

array[front] = key ;            // insert current element into Deque
}

// insert element at the rear end of deque
void Deque ::insertrear(int key)
{
if (isFull()) {
return;
    }

    //  If queue is initially empty,set front=rear=0; start of deque
if (front == -1) {
front = 0;
rear = 0;
    }
else if (rear == size-1)               // rear is at last position of queue
rear = 0;
else                            // increment rear by 1 position
rear = rear+1;

array[rear] = key ;         // insert current element into Deque
}

// Delete element at front of Deque
void Deque ::deletefront()
{
if (isEmpty())
   {

return ;
    }

    // Deque has only one element
 if (front == rear)
    {
front = -1;
rear = -1;
    }
else
        // back to initial position
if (front == size -1)
front = 0;

else // remove current front value from Deque;increment front by 1
front = front+1;
}

// Delete element at rear end of Deque
void Deque::deleterear()
{
if (isEmpty())
    {
        return ;
    }

    // Deque has only one element
if (front == rear)
    {
front = -1;
rear = -1;
    }
else if (rear == 0)
rear = size-1;
else
rear = rear-1;
}
// retrieve front element of Deque
int Deque::getFront()
{
if (isEmpty())
{
return -1 ;
}
return array[front];
}

// retrieve rear element of Deque
int Deque::getRear()
{
if(isEmpty() || rear < 0)
{
        return -1 ;
}
return array[rear];
}

int main()
{
        in(n)
        Deque dq(n);
        queue <int> q;
        stack <int> s;
        int arr[n];
        re(i,n)
        cin>>arr[i];
        int i=0;
        vi v;
        while(i<n-2)
        {
                if(!arr[i])
                {
                        if(v.size()==0)
                                cout<<"0"<<endl;
                        else if(v.size()==1)
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                //s.pop();
                        }
                        else if(v.size()==2)
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                //s.pop();
                                //q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue popFront"<<endl;
                                //s.pop();
                                //q.pop();
                                //dq.deletefront();
                        }
                        i++;
                }
                else
                {
                        v.clear();
                        while(i<n && arr[i])
                        {
                                v.pb(arr[i]);
                                i++;
                        }
                        sort(v.begin(),v.end(),greater <int>());
                        if(v.size()==1)
                        {
                                //s.push(v[0]);
                                cout<<"pushStack"<<endl;
                        }
                        else if(v.size()==2)
                        {
                                //s.push(v[0]);
                                //q.push(v[1]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                        }
                        else
                        {
                                //s.push(v[0]);
                                //q.push(v[1]);
                                //dq.insertfront(v[2]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                                cout<<"pushFront"<<endl;
                                for(int j=3;j<v.size();j++)
                                {
                                        //dq.insertrear(v[j]);
                                        cout<<"pushBack"<<endl;

                                }
                        }
                }
        }
        if(i<n)
        {
                while(i<n)
                {
                if(!arr[i])
                {
                        if(v.size()==0)
                                cout<<"0"<<endl;
                        else if(v.size()==1)
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                //s.pop();
                        }
                        else if(v.size()==2)
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                //s.pop();
                                //q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue popFront"<<endl;
                                //s.pop();
                                //q.pop();
                                //dq.deletefront();
                        }
                }
                else
                {
                        v.clear();
                        while(i<n && arr[i])
                        {
                                v.pb(arr[i]);
                                i++;
                        }
                        i++;
                        sort(v.begin(),v.end(),greater <int>());
                        if(v.size()==1)
                        {
                                //s.push(v[0]);
                                cout<<"pushStack"<<endl;
                        }
                        else if(v.size()==2)
                        {
                                //s.push(v[0]);
                                //q.push(v[1]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                        }
                        else
                        {
                                //s.push(v[0]);
                                //q.push(v[1]);
                                //dq.insertfront(v[2]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                                cout<<"pushFront"<<endl;
                                for(int j=3;j<v.size();j++)
                                {
                                        //dq.insertrear(v[j]);
                                        cout<<"pushBack"<<endl;

                                }
                        }
                }
                i++;
                }
        }
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define in(x) int x; cin>>x;
#define sin(s) string s; cin>>s;
#define ll long long
#define lin(x) ll x; cin>>x;
#define vi vector<int>
#define vll vector<ll>
#define si set<int>
#define pb push_back
#define re(i,n) for(ll i=0; i<n; i++)
#define pe(i,a,b) for(ll i=a; i<=b; i++)
#define rre(i,n) for(int i=n-1; i>-1; i--)
#define mp make_pair
#define pii pair<ll,ll>
#define endl "\n"
#define pi 3.1415926536
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define mod 1000000007
#define inf INT_MAX
#define ninf -INT_MAX
/////////////////////////////////////////////////////////////////////////////////

bool compare(const pair<pair<int, int>,int>&i, const pair<pair<int, int>,int>&j)
{
        return i.first.first<j.first.first;
}
/////////////////////////////////////////////////////////////////////////////////
//vi v;
int ncr(int n, int k)
{
        if(n<k)
                return 0;
        int C[n + 1][k + 1];
        int i, j;
        for (i = 0; i <= n; i++)
        {
                for (j = 0; j <= min(i, k); j++)
                {
                        if (j == 0 || j == i)
                                C[i][j] = 1;
                        else
                                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j])%mod;
                }
        }
        return C[n][k];
}
////////////////////////////////////////////////////////////////////////////
ll modpowIter(ll a, ll b, ll c)
{
        int ans=1;
        while(b != 0)
        {
                if(b%2 == 1)
                ans=(ans*a)%c;
                a=(a*a)%c;
                b /= 2;
        }
        return ans;
}
///////////////////////////////////////////////////////////////////////////////
string intobin(int n)
{
        string s="";
        if(n==0)
                s="0";
        while(n)
        {
                if(n%2)
                        s="1"+s;
                else
                        s="0"+s;
                n/=2;
        }
        return s;
}

////////////////////////////////////////////////////////////////////////////////
vll v;
int bintoin(string s)
{
        v.pb(1);
        re(i,101)
        {
                v.pb((v[v.size()-1]*2)%mod);
        }
        ll n=0;
        rre(i,s.length())
        {
                n=((n+(s[i]-'0')*v[s.length()-i-1])%mod)%mod;
                //cout<<v[s.length()-i-1]<<endl;
        }
        return n;
}
//////////////////////////////////////////////////////////////////////////////////
ll nc2(ll n, ll k)
{
        if(n<k)
                return 0;
        return (n*(n-1))/2;
}
///////////////////////////////////////////////////////////////////////////////////
bool prime[1000001];
void SieveOfEratosthenes(int n)
{
        memset(prime, true, sizeof(prime));
        for (int p=2; p*p<=n; p++)
        {
                if (prime[p] == true)
                {
                        for (int i=p*p; i<=n; i += p)
                        prime[i] = false;
                }
        }
        /*for (int p=2; p<=n; p++)
                if (prime[p])
                        v.pb(p);  */
}
////////////////////////////////////////////////////////////////////////////////////
ll p(ll a, ll b){
        long long x=1, y=a;
        while (b > 0)
        {
                if (b%2 == 1)
                {
                        x = (x*y) % mod;
                }
                y = (y*y) % mod;
                b /= 2;
        }
        return x % mod;
}

ll inv(ll a)
{
        return p(a, mod-2);
}
//////////////////////////////////////////////////////////////////////////////////////

class Deque
{
int  array[100001];
int  front;
int  rear;
int  size;
public :
Deque(int size) {
front = -1;
rear = 0;
this->size = size;
    }

    // Operations on Deque:
void  insertfront(int key);
void  insertrear(int key);
void  deletefront();
void  deleterear();
int  getFront();
int  getRear();

    // Check if Deque is full
bool  isFull(){
return ((front == 0 && rear == size-1)||front == rear+1);
    }
    // Check if Deque is empty
bool  isEmpty(){
return (front == -1);
    }
};

// Insert an element at front of the deque
void Deque::insertfront(int key)
{
if (isFull())  {
return;
    }

    // If queue is initially empty,set front=rear=0; start of deque
if (front == -1)  {
front = 0;
rear = 0;
    }
else if (front == 0)              // front is first position of queue
front = size - 1 ;
else // decrement front 1 position
front = front-1;

array[front] = key ;            // insert current element into Deque
}

// insert element at the rear end of deque
void Deque ::insertrear(int key)
{
if (isFull()) {
return;
    }

    //  If queue is initially empty,set front=rear=0; start of deque
if (front == -1) {
front = 0;
rear = 0;
    }
else if (rear == size-1)               // rear is at last position of queue
rear = 0;
else                            // increment rear by 1 position
rear = rear+1;

array[rear] = key ;         // insert current element into Deque
}

// Delete element at front of Deque
void Deque ::deletefront()
{
if (isEmpty())
   {

return ;
    }

    // Deque has only one element
 if (front == rear)
    {
front = -1;
rear = -1;
    }
else
        // back to initial position
if (front == size -1)
front = 0;

else // remove current front value from Deque;increment front by 1
front = front+1;
}

// Delete element at rear end of Deque
void Deque::deleterear()
{
if (isEmpty())
    {
        return ;
    }

    // Deque has only one element
if (front == rear)
    {
front = -1;
rear = -1;
    }
else if (rear == 0)
rear = size-1;
else
rear = rear-1;
}
// retrieve front element of Deque
int Deque::getFront()
{
if (isEmpty())
{
return -1 ;
}
return array[front];
}

// retrieve rear element of Deque
int Deque::getRear()
{
if(isEmpty() || rear < 0)
{
        return -1 ;
}
return array[rear];
}

int main()
{
        in(n)
        Deque dq(n);
        queue <int> q;
        stack <int> s;
        int arr[n];
        re(i,n)
        cin>>arr[i];
        int i=0;
        while(i<n-2)
        {
                if(!arr[i])
                {
                        if(s.size()==0 && q.size()==0 && dq.isEmpty())
                                cout<<"0"<<endl;
                        else if(s.size() && q.size()==0 && dq.isEmpty())
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                s.pop();
                        }
                        else if(s.size() && q.size() && dq.isEmpty())
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                s.pop();
                                q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue ";
                                s.pop();
                                q.pop();
                                if(dq.getRear()>dq.getFront())
                                {
                                        cout<<"popBack"<<endl;
                                        dq.deleterear();
                                }
                                else
                                {
                                        cout<<"popFront"<<endl;
                                        dq.deletefront();
                                }
                        }
                        i++;
                }
                else
                {
                        vi v;
                        while(i<n && arr[i])
                        {
                                v.pb(arr[i]);
                                i++;
                        }
                        sort(v.begin(),v.end(),greater <int>());
                        if(v.size()==1)
                        {
                                s.push(v[0]);
                                cout<<"pushStack"<<endl;
                        }
                        else if(v.size()==2)
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                        }
                        else
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                dq.insertfront(v[2]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                                cout<<"pushFront"<<endl;
                                for(int j=v.size()-1;j>2;j--)
                                {
                                        if(v[j]<=dq.getFront() && v[j]<=dq.getRear())
                                        {
                                                if(dq.getFront()-v[j]<dq.getRear()-v[j])
                                                {
                                                        dq.insertfront(v[j]);
                                                        cout<<"pushFront"<<endl;
                                                }
                                                else
                                                {
                                                        dq.insertrear(v[j]);
                                                        cout<<"pushBack"<<endl;
                                                }
                                        }
                                        else if(v[j]>=dq.getFront() && v[j]<=dq.getRear())
                                        {
                                                dq.insertfront(v[j]);
                                                cout<<"pushFront"<<endl;
                                        }
                                        else if(v[j]<=dq.getFront() && v[j]>=dq.getRear())
                                        {
                                                dq.insertrear(v[j]);
                                                cout<<"pushBack"<<endl;
                                        }
                                        else
                                        {
                                                if(dq.getFront()-v[j]>dq.getRear()-v[j])
                                                {
                                                        dq.insertfront(v[j]);
                                                        cout<<"pushFront"<<endl;
                                                }
                                                else
                                                {
                                                        dq.insertrear(v[j]);
                                                        cout<<"pushBack"<<endl;
                                                }
                                        }
                                }
                        }
                }
        }
        if(i<n)
        {
                while(i<n)
                {
                if(!arr[i])
                {
                        if(s.size()==0 && q.size()==0 && dq.isEmpty())
                                cout<<"0"<<endl;
                        else if(s.size() && q.size()==0 && dq.isEmpty())
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                s.pop();
                        }
                        else if(s.size() && q.size() && dq.isEmpty())
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                s.pop();
                                q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue ";
                                s.pop();
                                q.pop();
                                if(dq.getRear()>dq.getFront())
                                {
                                        cout<<"popBack"<<endl;
                                        dq.deleterear();
                                }
                                else
                                {
                                        cout<<"popFront"<<endl;
                                        dq.deletefront();
                                }
                        }
                }
                else
                {
                        vi v;
                        while(i<n && arr[i])
                        {
                                v.pb(arr[i]);
                                i++;
                        }
                        i++;
                        sort(v.begin(),v.end(),greater <int>());
                        if(v.size()==1)
                        {
                                s.push(v[0]);
                                cout<<"pushStack"<<endl;
                        }
                        else if(v.size()==2)
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                        }
                        else
                        {
                                s.push(v[0]);
                                q.push(v[1]);
                                dq.insertfront(v[2]);
                                cout<<"pushStack"<<endl;
                                cout<<"pushQueue"<<endl;
                                cout<<"pushFront"<<endl;
                                for(int j=v.size()-1;j>2;j--)
                                {
                                        if(v[j]<=dq.getFront() && v[j]<=dq.getRear())
                                        {
                                                if(dq.getFront()-v[j]<dq.getRear()-v[j])
                                                {
                                                        dq.insertfront(v[j]);
                                                        cout<<"pushFront"<<endl;
                                                }
                                                else
                                                {
                                                        dq.insertrear(v[j]);
                                                        cout<<"pushBack"<<endl;
                                                }
                                        }
                                        else if(v[j]>=dq.getFront() && v[j]<=dq.getRear())
                                        {
                                                dq.insertfront(v[j]);
                                                cout<<"pushFront"<<endl;
                                        }
                                        else if(v[j]<=dq.getFront() && v[j]>=dq.getRear())
                                        {
                                                dq.insertrear(v[j]);
                                                cout<<"pushBack"<<endl;
                                        }
                                        else
                                        {
                                                if(dq.getFront()-v[j]>dq.getRear()-v[j])
                                                {
                                                        dq.insertfront(v[j]);
                                                        cout<<"pushFront"<<endl;
                                                }
                                                else
                                                {
                                                        dq.insertrear(v[j]);
                                                        cout<<"pushBack"<<endl;
                                                }
                                        }
                                }
                        }
                }
                i++;
                }
        }
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define in(x) int x; cin>>x;
#define sin(s) string s; cin>>s;
#define ll long long
#define lin(x) ll x; cin>>x;
#define vi vector<int>
#define vll vector<ll>
#define si set<int>
#define pb push_back
#define re(i,n) for(ll i=0; i<n; i++)
#define pe(i,a,b) for(ll i=a; i<=b; i++)
#define rre(i,n) for(int i=n-1; i>-1; i--)
#define mp make_pair
#define pii pair<ll,ll>
#define endl "\n"
#define pi 3.1415926536
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define mod 1000000007
#define inf INT_MAX
#define ninf -INT_MAX
/////////////////////////////////////////////////////////////////////////////////

bool compare(const pair<int,int>&i, const pair<int,int>&j)
{
        return i.first>j.first;
}
/////////////////////////////////////////////////////////////////////////////////
//vi v;
int ncr(int n, int k)
{
        if(n<k)
                return 0;
        int C[n + 1][k + 1];
        int i, j;
        for (i = 0; i <= n; i++)
        {
                for (j = 0; j <= min(i, k); j++)
                {
                        if (j == 0 || j == i)
                                C[i][j] = 1;
                        else
                                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j])%mod;
                }
        }
        return C[n][k];
}
////////////////////////////////////////////////////////////////////////////
ll modpowIter(ll a, ll b, ll c)
{
        int ans=1;
        while(b != 0)
        {
                if(b%2 == 1)
                ans=(ans*a)%c;
                a=(a*a)%c;
                b /= 2;
        }
        return ans;
}
///////////////////////////////////////////////////////////////////////////////
string intobin(int n)
{
        string s="";
        if(n==0)
                s="0";
        while(n)
        {
                if(n%2)
                        s="1"+s;
                else
                        s="0"+s;
                n/=2;
        }
        return s;
}

////////////////////////////////////////////////////////////////////////////////
vll v;
int bintoin(string s)
{
        v.pb(1);
        re(i,101)
        {
                v.pb((v[v.size()-1]*2)%mod);
        }
        ll n=0;
        rre(i,s.length())
        {
                n=((n+(s[i]-'0')*v[s.length()-i-1])%mod)%mod;
                //cout<<v[s.length()-i-1]<<endl;
        }
        return n;
}
//////////////////////////////////////////////////////////////////////////////////
ll nc2(ll n, ll k)
{
        if(n<k)
                return 0;
        return (n*(n-1))/2;
}
///////////////////////////////////////////////////////////////////////////////////
bool prime[1000001];
void SieveOfEratosthenes(int n)
{
        memset(prime, true, sizeof(prime));
        for (int p=2; p*p<=n; p++)
        {
                if (prime[p] == true)
                {
                        for (int i=p*p; i<=n; i += p)
                        prime[i] = false;
                }
        }
        /*for (int p=2; p<=n; p++)
                if (prime[p])
                        v.pb(p);  */
}
////////////////////////////////////////////////////////////////////////////////////
ll p(ll a, ll b){
        long long x=1, y=a;
        while (b > 0)
        {
                if (b%2 == 1)
                {
                        x = (x*y) % mod;
                }
                y = (y*y) % mod;
                b /= 2;
        }
        return x % mod;
}

ll inv(ll a)
{
        return p(a, mod-2);
}
//////////////////////////////////////////////////////////////////////////////////////

int main()
{
        in(n)
        int arr[n];
        re(i,n)
        cin>>arr[i];
        int i=0;
        vector <pair<int,int>> v;
        map <int,string> m;
        while(i<n-2)
        {
                if(!arr[i])
                {
                        //cout<<"v.size()  "<<v.size()<<endl;
                        if(v.size()==0)
                                cout<<"0"<<endl;
                        else if(v.size()==1)
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                //s.pop();
                        }
                        else if(v.size()==2)
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                //s.pop();
                                //q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue popFront"<<endl;
                                //s.pop();
                                //q.pop();
                                //dq.deletefront();
                        }
                        i++;
                        v.clear();
                }
                else
                {
                        while(i<n && arr[i])
                        {
                                v.pb({arr[i],i});
                                i++;
                        }
                        //cout<<"v.size()  ****"<<v.size()<<endl;
                        sort(v.begin(),v.end(),compare);
                        if(v.size()==1)
                        {
                                //s.push(v[0]);
                                m[v[0].second]="pushStack";
                        }
                        else if(v.size()==2)
                        {
                                //s.push(v[0]);
                                //q.push(v[1]);
                                m[v[1].second]="pushStack";
                                m[v[0].second]="pushQueue";
                        }
                        else
                        {
                                //s.push(v[0]);
                                //q.push(v[1]);
                                //dq.insertfront(v[2]);
                                m[v[0].second]="pushFront";
                                m[v[1].second]="pushQueue";
                                m[v[2].second]="pushStack";

                                for(int j=3;j<v.size();j++)
                                {
                                        //dq.insertrear(v[j]);
                                        m[v[j].second]="pushBack";

                                }
                        }
                        for(int j=i-v.size();j<i;j++)
                                cout<<m[j]<<endl;
                }
        }
        if(i<n)
        {
                while(i<n)
                {
                if(!arr[i])
                {
                        //cout<<"v.size()  ===="<<v.size()<<endl;
                        if(v.size()==0)
                                cout<<"0"<<endl;
                        else if(v.size()==1)
                        {
                                cout<<1<<" "<<"popStack"<<endl;
                                //s.pop();
                        }
                        else if(v.size()==2)
                        {
                                cout<<"2 popStack popQueue"<<endl;
                                //s.pop();
                                //q.pop();
                        }
                        else
                        {
                                cout<<"3 popStack popQueue popFront"<<endl;
                                //s.pop();
                                //q.pop();
                                //dq.deletefront();
                        }
                        v.clear();
                }
                else
                {
                        while(i<n && arr[i])
                        {
                                v.pb({arr[i],i});
                                i++;
                        }
                        //cout<<"v.size()  ****"<<v.size()<<endl;
                        sort(v.begin(),v.end(),compare);
                        if(v.size()==1)
                        {
                                //s.push(v[0]);
                                m[v[0].second]="pushStack";
                        }
                        else if(v.size()==2)
                        {
                                //s.push(v[0]);
                                //q.push(v[1]);
                                m[v[1].second]="pushStack";
                                m[v[0].second]="pushQueue";
                        }
                        else
                        {
                                //s.push(v[0]);
                                //q.push(v[1]);
                                //dq.insertfront(v[2]);
                                m[v[0].second]="pushFront";
                                m[v[1].second]="pushQueue";
                                m[v[2].second]="pushStack";

                                for(int j=3;j<v.size();j++)
                                {
                                        //dq.insertrear(v[j]);
                                        m[v[j].second]="pushBack";

                                }
                        }
                        for(int j=i-v.size();j<i;j++)
                                cout<<m[j]<<endl;
                }
                i++;
                }
        }
        return 0;
}


// g++ -std=c++14

#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

int main(){
  int n;
  cin>>n;
  int a,b,c,temp;
  vector<int> v;
  while(n--){
    cin>>temp;
    if(temp==0){
      if(v.size()==0){
        cout<<0<<endl;
      }
      else if(v.size()==1){
        cout<<"pushStack \n1 popStack\n";
      }
      else if(v.size()==2){
        cout<<"pushStack \npushQueue \n2 popStack popQueue\n";
      }
      else{
        // cout<<v<<endl;
        vector<pair<int,int> > nos;
        for(int i=0;i<v.size();i++){
          nos.pb(mp(v[i],i));
        }
        sort(nos.begin(),nos.end());
        reverse(nos.begin(),nos.end());
        a = nos[0].fi;
        b = nos[1].fi;
        c = nos[2].fi;
        multiset<int> s;
        s.insert(a);
        s.insert(b);
        s.insert(c);
        int done=0;
        for(int i=0;i<v.size();i++){
          if(done==0){
            if(s.find(v[i])==s.end()){
              cout<<"pushStack\n";
              s.erase(v[i]);
            }
            else{
              cout<<"pushStack\n";
              done=1;
            }
          }
          else if(done==1){
            if(s.find(v[i])==s.end()){
              cout<<"pushFront\n";
              s.erase(v[i]);
            }
            else{
              cout<<"pushFront\n";
              done=2;
            }
          }
          else if(done==2){
            if(s.find(v[i])==s.end()){
              cout<<"pushBack\n";
              s.erase(v[i]);
            }
            else{
              cout<<"pushQueue\n";
              done=3;
            }
          }
          else{
            cout<<"pushBack\n";
          }
        }
        cout<<3<<" "<<"popStack popFront popQueue\n";
      }
      v.clear();
    }
    else{
      v.pb(temp);
    }
  }
}


// g++ -std=c++14

#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

int main(){
  int n;
  cin>>n;
  int a,b,c,temp;
  vector<int> v;
  int tt = 0;
  while(n--){
    if(tt==0)
      cin>>temp;
    else{
      temp = 0;
    }
    if(temp==0){
      // cout<<v<<endl;
      if(v.size()==0){
        cout<<0<<endl;
      }
      else if(v.size()==1){
        cout<<"pushStack"<<endl;
        if(tt==0){
            cout<<"1 popStack\n";
        }
      }
      else if(v.size()==2){
        cout<<"pushStack"<<endl<<"pushQueue"<<endl;
        if(tt==0){
            cout<<"2 popStack popQueue\n";
        }
      }
      else{
        // cout<<v<<endl;
        vector<pair<int,int> > nos;
        for(int i=0;i<v.size();i++){
          nos.pb(mp(v[i],i));
        }
        sort(nos.begin(),nos.end());
        reverse(nos.begin(),nos.end());
        a = nos[0].fi;
        b = nos[1].fi;
        c = nos[2].fi;
        multiset<int> s;
        s.insert(a);
        s.insert(b);
        s.insert(c);
        int done=0;
        for(int i=0;i<v.size();i++){
          if(done==0){
            if(s.find(v[i])==s.end()){
              cout<<"pushStack"<<endl;
            }
            else{
              cout<<"pushStack"<<endl;
              s.erase(v[i]);
              done=1;
            }
          }
          else if(done==1){
            if(s.find(v[i])==s.end()){
              cout<<"pushFront"<<endl;
            }
            else{
              cout<<"pushFront"<<endl;
              s.erase(v[i]);
              done=2;
            }
          }
          else if(done==2){
            if(s.find(v[i])==s.end()){
              cout<<"pushBack"<<endl;
            }
            else{
              cout<<"pushQueue"<<endl;
              s.erase(v[i]);
              done=3;
            }
          }
          else{
            cout<<"pushBack"<<endl;
          }
        }
        if(tt==0)
          cout<<3<<" "<<"popStack popFront popQueue"<<endl;
      }
      v.clear();
    }
    else{
      v.pb(temp);
      // tr(n);
      if(n==0){
        // v.pb(0);
        n++;
        tt = 1;
      }
    }
  }
}


// g++ -std=c++14

#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

int main(){
  int n;
  cin>>n;
  int a,b,c,temp;
  vector<int> v;
  int tt = 0;
  while(n--){
    if(tt==0)
      cin>>temp;
    else{
      temp = 0;
    }
    if(temp==0){
      // cout<<v<<endl;
      if(v.size()==0){
        cout<<0<<endl;
      }
      else if(v.size()==1){
        cout<<"pushStack"<<endl;
        if(tt==0){
            cout<<"1 popStack\n";
        }
      }
      else if(v.size()==2){
        cout<<"pushStack"<<endl<<"pushQueue"<<endl;
        if(tt==0){
            cout<<"2 popStack popQueue\n";
        }
      }
      else{
        // cout<<v<<endl;
        vector<pair<int,int> > nos;
        for(int i=0;i<v.size();i++){
          nos.pb(mp(v[i],i));
        }
        sort(nos.begin(),nos.end());
        reverse(nos.begin(),nos.end());
        a = nos[0].fi;
        b = nos[1].fi;
        c = nos[2].fi;
        multiset<int> s;
        s.insert(a);
        s.insert(b);
        s.insert(c);
        // tr(a,b,c);
        int done=0;
        for(int i=0;i<v.size();i++){
          // tr(v[i]);
          if(done==0){
            if(s.find(v[i])==s.end()){
              cout<<"pushStack"<<endl;
            }
            else{
              cout<<"pushStack"<<endl;
              auto itr = s.find(v[i]);
              s.erase(itr);
              done=1;
            }
          }
          else if(done==1){
            if(s.find(v[i])==s.end()){
              cout<<"pushFront"<<endl;
            }
            else{
              cout<<"pushFront"<<endl;
              auto itr = s.find(v[i]);
              s.erase(itr);
              done=2;
            }
          }
          else if(done==2){
            if(s.find(v[i])==s.end()){
              cout<<"pushBack"<<endl;
            }
            else{
              cout<<"pushQueue"<<endl;
              auto itr = s.find(v[i]);
              s.erase(itr);
              done=3;
            }
          }
          else{
            cout<<"pushBack"<<endl;
          }
        }
        if(tt==0)
          cout<<3<<" "<<"popStack popFront popQueue"<<endl;
      }
      v.clear();
    }
    else{
      v.pb(temp);
      // tr(n);
      if(n==0){
        // v.pb(0);
        n++;
        tt = 1;
      }
    }
  }
}


// g++ -std=c++14

#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

int main(){
  int n;
  cin>>n;
  int a,b,c,temp;
  vector<int> v;
  while(n--){
    cin>>temp;
    if(temp==0){
      if(v.size()==0){
        cout<<0<<endl;
      }
      else if(v.size()==1){
        cout<<"pushStack"<<endl<<"1 popStack\n";
      }
      else if(v.size()==2){
        cout<<"pushStack"<<endl<<"pushQueue"<<endl<<"2 popStack popQueue\n";
      }
      else{
        // cout<<v<<endl;
        vector<pair<int,int> > nos;
        for(int i=0;i<v.size();i++){
          nos.pb(mp(v[i],i));
        }
        sort(nos.begin(),nos.end());
        reverse(nos.begin(),nos.end());
        a = nos[0].fi;
        b = nos[1].fi;
        c = nos[2].fi;
        multiset<int> s;
        s.insert(a);
        s.insert(b);
        s.insert(c);
        int done=0;
        for(int i=0;i<v.size();i++){
          if(done==0){
            if(s.find(v[i])==s.end()){
              cout<<"pushStack"<<endl;
              s.erase(v[i]);
            }
            else{
              cout<<"pushStack"<<endl;
              done=1;
            }
          }
          else if(done==1){
            if(s.find(v[i])==s.end()){
              cout<<"pushFront"<<endl;
              s.erase(v[i]);
            }
            else{
              cout<<"pushFront"<<endl;
              done=2;
            }
          }
          else if(done==2){
            if(s.find(v[i])==s.end()){
              cout<<"pushBack"<<endl;
              s.erase(v[i]);
            }
            else{
              cout<<"pushQueue"<<endl;
              done=3;
            }
          }
          else{
            cout<<"pushBack"<<endl;
          }
        }
        cout<<3<<" "<<"popStack popFront popQueue"<<endl;
      }
      v.clear();
    }
    else{
      v.pb(temp);
    }
  }
}