// 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;
              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;
          }
        }
        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;
      }
    }
  }
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,m,t,q,z;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
unordered_map<lli,lli> mm,mm1,mm2;
struct edge
{
    lli first,second,third;
};
vector<edge> vv;

vector<ll> v[200005];
//set<lli> s;
map<lli,lli> mk;
//int f=0;
map<ll,lli> bb;
//lli mx=-1;
//lli a[200005];
lli mi=1e18;
ll p[200005];
lli mx=1;
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d,fl;
map<ll,lli> allow;
lli a[100005];
lli b[505][505];
lli tot=1e18;
map<lli,lli> vis;
string s1="\0";
string s2="\0";
string s;
string ss;
lli f=0;
map<ll,lli> ml;
int ff;
void dfs(lli i,lli mi,lli root)
{
    vis[i]=1;
    if(v[i].size()==0)
    {
        vv.push_back({root,i,mi});
        ff=1;
        return;
    }
    for(int j=0;j<v[i].size();j++)
    {
        if(vis[v[i][j].first]==0)
        {
            lli d=min(mi,v[i][j].second);
            dfs(v[i][j].first,d,root);
        }
    }
}
lli aa(string s)
{
    lli cnt=0;
    lli ans=0;
    for(int j=0;j<s.length();j++)
    {
        if(s[j]>'0')
        {
            if(s[j]>'1')
            {
            for(int hh=0;hh<=3-cnt-1;hh++)
            {
            if(hh==0)
            ans+=(s[j]-'0')-1;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*(k)*9;
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*((k*(k-1))/2)*9*9;
            }
            }
            }
            for(int hh=0;hh<=3-cnt;hh++)
            {
            if(hh==0)
            ans++;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((k)*9);
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+(((k*(k-1))/2)*9*9);
            }
            else
            {
                lli k=s.length()-j-1;
            ans=ans+(((k*(k-1)*(k-2))/6)*9*9*9);
            }
            //cout<<hh<<" "<<j+1<<" "<<ans<<endl;
            }
            //ans+=
            cnt++;
        }
    }
    return ans;
}
map<lli,lli> dp,dp1;
int main()
{
cin>>n;
queue<lli> q;
deque<lli> d;
stack<lli> s;
lli x;
multiset<lli,greater<lli>> mm;
lli cnt=0;
lli tot=0;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]>0)
    {}//mm.insert(a[i]);
    else
    cnt++;
}
for(int i=1;i<=n;i++)
{
    if(a[i]>0&&tot<=3*cnt)
    mm.insert(a[i]),tot++;
}
lli front=0;
lli level=1;
lli kk=1;
for(int i=1;i<=n;i++)
{
    if(a[i]>0&&mm.count(a[i])>0)
    {
        if(kk==1)
        {
            cout<<"pushStack\n";
            s.push(a[i]);
            kk++;
        }
        else if(kk==2)
        {
            cout<<"pushQueue\n";
            q.push(a[i]);
            kk++;
        }
        else if(kk==3)
        {
            cout<<"pushFront\n";
            d.push_front(a[i]);
            kk++;
            front++;
        }
        if(kk==4)
        {
            kk=1;
            //level++;
        }
    }
    else if(a[i]>0)
    {
        cout<<"pushBack\n";
        d.push_back(a[i]);
    }
    else
    {
        map<string,lli> ms;
        lli op=0;
        while(!s.empty())
        {
            if(op<1)
            {
            ms["popStack"]++;
            op++;
            s.pop();
            }
            else
            break;
        }
        while(!q.empty())
        {
            if(op<2)
            {
            ms["popQueue"]++;
            op++;
            q.pop();
            }
            else
            break;
        }
        while(!d.empty())
        {
            if(op<3)
            {
            ms["popFront"]++;
            op++;
            d.pop_front();
            }
            else
            break;
        }
        if(op>0)
        cout<<op<<" ";
        else
        cout<<op;
        for(auto &i:ms)
        {
            if(op>1)
            cout<<i.first<<" ",op--;
            else
            cout<<i.first,op--;
        }
        cout<<"\n";
        kk=1;
    }
}
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,m,t,q,z;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
unordered_map<lli,lli> mm,mm1,mm2;
struct edge
{
    lli first,second,third;
};
vector<edge> vv;

vector<ll> v[200005];
//set<lli> s;
map<lli,lli> mk;
//int f=0;
map<ll,lli> bb;
//lli mx=-1;
//lli a[200005];
lli mi=1e18;
ll p[200005];
lli mx=1;
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d,fl;
map<ll,lli> allow;
lli a[100005];
lli b[505][505];
lli tot=1e18;
map<lli,lli> vis;
string s1="\0";
string s2="\0";
string s;
string ss;
lli f=0;
map<ll,lli> ml;
int ff;
void dfs(lli i,lli mi,lli root)
{
    vis[i]=1;
    if(v[i].size()==0)
    {
        vv.push_back({root,i,mi});
        ff=1;
        return;
    }
    for(int j=0;j<v[i].size();j++)
    {
        if(vis[v[i][j].first]==0)
        {
            lli d=min(mi,v[i][j].second);
            dfs(v[i][j].first,d,root);
        }
    }
}
lli aa(string s)
{
    lli cnt=0;
    lli ans=0;
    for(int j=0;j<s.length();j++)
    {
        if(s[j]>'0')
        {
            if(s[j]>'1')
            {
            for(int hh=0;hh<=3-cnt-1;hh++)
            {
            if(hh==0)
            ans+=(s[j]-'0')-1;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*(k)*9;
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*((k*(k-1))/2)*9*9;
            }
            }
            }
            for(int hh=0;hh<=3-cnt;hh++)
            {
            if(hh==0)
            ans++;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((k)*9);
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+(((k*(k-1))/2)*9*9);
            }
            else
            {
                lli k=s.length()-j-1;
            ans=ans+(((k*(k-1)*(k-2))/6)*9*9*9);
            }
            //cout<<hh<<" "<<j+1<<" "<<ans<<endl;
            }
            //ans+=
            cnt++;
        }
    }
    return ans;
}
map<lli,lli> dp,dp1;
int main()
{
cin>>n;
queue<lli> q;
deque<lli> d;
stack<lli> s;
lli x;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
}
for(int i=1;i<=n;i++)
{
    x=a[i];
    if(x==0)
    {
        if(s.empty()&&q.empty()&&d.empty())
        cout<<"0\n";
        else
        {
            multimap<lli,string,greater<lli>> ml;
            if(!s.empty())
            {
                ml.insert({s.top(),"popStack"});
            }
            if(!q.empty())
            ml.insert({q.front(),"popQueue"});
            if(!d.empty())
            {
                if(d.size()>1)
                ml.insert({d.front(),"popFront"}),ml.insert({d.back(),"popBack"});
                else
                ml.insert({d.front(),"popFront"});
            }
            lli cnt=1;
            lli ms=ml.size();
            cout<<min(ms,3ll)<<" ";
            for(auto &i: ml)
            {
                if(cnt<=3)
                {
                    cout<<i.second<<" ";
                    if(i.second=="popStack")
                    s.pop();
                    else if(i.second=="popQueue")
                    q.pop();
                    else if(i.second=="popFront")
                    d.pop_front();
                    else
                    d.pop_back();
                }
                cnt++;
            }
            cout<<"\n";
            ml.clear();
        }
    }
    else
    {
        if(s.empty())
        {
            s.push(x);
            cout<<"pushStack\n";
        }
        else if(q.empty())
        {
            q.push(x);
            cout<<"pushQueue\n";
        }
        else if(d.size()<=1)
        {
            d.push_front(x);
            cout<<"pushFront\n";
        }
        else
        {
            multimap<lli,string> ml;
            ml.insert({s.top(),"pushStack"});
            ml.insert({q.front(),"pushQueue"});
            ml.insert({d.front(),"pushFront"});
            ml.insert({d.back(),"pushBack"});
            string ss=ml.begin()->second;
            if(ss=="pushStack")
            {
                cout<<ss<<"\n";
                s.push(x);
            }
            else if(ss=="pushQueue")
            {
                cout<<ss<<"\n";
                q.push(x);
            }
            else if(ss=="pushFront")
            {
                cout<<ss<<"\n";
                d.push_front(x);
            }
            else
            {
                cout<<ss<<"\n";
                d.push_back(x);
            }
            ml.clear();
        }
    }
}
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,m,t,q,z;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
unordered_map<lli,lli> mm,mm1,mm2;
struct edge
{
    lli first,second,third;
};
vector<edge> vv;

vector<ll> v[200005];
//set<lli> s;
map<lli,lli> mk;
//int f=0;
map<ll,lli> bb;
//lli mx=-1;
//lli a[200005];
lli mi=1e18;
ll p[200005];
lli mx=1;
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d,fl;
map<ll,lli> allow;
lli a[100005];
lli b[505][505];
lli tot=1e18;
map<lli,lli> vis;
string s1="\0";
string s2="\0";
string s;
string ss;
lli f=0;
map<ll,lli> ml;
int ff;
void dfs(lli i,lli mi,lli root)
{
    vis[i]=1;
    if(v[i].size()==0)
    {
        vv.push_back({root,i,mi});
        ff=1;
        return;
    }
    for(int j=0;j<v[i].size();j++)
    {
        if(vis[v[i][j].first]==0)
        {
            lli d=min(mi,v[i][j].second);
            dfs(v[i][j].first,d,root);
        }
    }
}
lli aa(string s)
{
    lli cnt=0;
    lli ans=0;
    for(int j=0;j<s.length();j++)
    {
        if(s[j]>'0')
        {
            if(s[j]>'1')
            {
            for(int hh=0;hh<=3-cnt-1;hh++)
            {
            if(hh==0)
            ans+=(s[j]-'0')-1;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*(k)*9;
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*((k*(k-1))/2)*9*9;
            }
            }
            }
            for(int hh=0;hh<=3-cnt;hh++)
            {
            if(hh==0)
            ans++;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((k)*9);
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+(((k*(k-1))/2)*9*9);
            }
            else
            {
                lli k=s.length()-j-1;
            ans=ans+(((k*(k-1)*(k-2))/6)*9*9*9);
            }
            //cout<<hh<<" "<<j+1<<" "<<ans<<endl;
            }
            //ans+=
            cnt++;
        }
    }
    return ans;
}
map<lli,lli> dp,dp1;
int main()
{
cin>>n;
queue<lli> q;
deque<lli> d;
stack<lli> s;
lli x;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
}
for(int i=1;i<=n;i++)
{
    x=a[i];
    if(x==0)
    {
        if(s.empty()&&q.empty()&&d.empty())
        cout<<"0\n";
        else
        {
            multimap<lli,string,greater<lli>> ml;
            if(!s.empty())
            {
                ml.insert({s.top(),"popStack"});
            }
            if(!q.empty())
            ml.insert({q.front(),"popQueue"});
            if(!d.empty())
            {
                if(d.size()>1)
                {
                    if(d.front()>d.back())
                    ml.insert({d.front(),"popFront"});
                    else
                    ml.insert({d.back(),"popBack"});
                }
                else
                ml.insert({d.front(),"popFront"});
            }
            lli cnt=1;
            lli ms=ml.size();
            ms=min(ms,3ll);
            cout<<min(ms,3ll)<<" ";
            for(auto &i: ml)
            {
                if(cnt<=3)
                {
                    if(cnt<ms)
                    cout<<i.second<<" ";
                    else
                    cout<<i.second;
                    if(i.second=="popStack")
                    s.pop();
                    else if(i.second=="popQueue")
                    q.pop();
                    else if(i.second=="popFront")
                    d.pop_front();
                    else
                    d.pop_back();
                }
                cnt++;
            }
            cout<<"\n";
            ml.clear();
        }
    }
    else
    {
        if(s.empty())
        {
            s.push(x);
            cout<<"pushStack\n";
        }
        else if(q.empty())
        {
            q.push(x);
            cout<<"pushQueue\n";
        }
        else if(d.size()<1)
        {
            d.push_front(x);
            cout<<"pushFront\n";
        }
        else if(d.size()>=1)
        {
            multimap<lli,string> ml;
            ml.insert({s.top(),"pushStack"});
            ml.insert({q.front(),"pushQueue"});
            if(d.size()==1)
            ml.insert({d.front(),"pushFront"});
            else
            {
                if(d.front()>d.back())
                ml.insert({d.front(),"pushFront"});
                else
                ml.insert({d.back(),"pushBack"});
            }
            string ss=ml.begin()->second;
            //cout<<ml.begin()->first<<endl;
            if(ml.begin()->first<=x)
            {
            if(ss=="pushStack")
            {
                cout<<ss<<"\n";
                s.push(x);
            }
            else if(ss=="pushQueue")
            {
                cout<<ss<<"\n";
                q.push(x);
            }
            else if(ss=="pushFront")
            {
                cout<<"pushFront"<<"\n";
                d.push_front(x);
            }
            }
            else
            {
                if(d.size()==1)
                {
                cout<<"pushBack\n";
                d.push_back(x);
                }
                else
                {
                    if(d.front()<d.back())
                    {
                        cout<<"pushFront\n";
                d.push_front(x);
                    }
                    else
                    {
                cout<<"pushBack\n";
                d.push_back(x);
                    }
                }
            }
            ml.clear();
        }
    }
}
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,m,t,q,z;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
unordered_map<lli,lli> mm,mm1,mm2;
struct edge
{
    lli first,second,third;
};
vector<edge> vv;

vector<ll> v[200005];
//set<lli> s;
map<lli,lli> mk;
//int f=0;
map<ll,lli> bb;
//lli mx=-1;
//lli a[200005];
lli mi=1e18;
ll p[200005];
lli mx=1;
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d,fl;
map<ll,lli> allow;
lli a[100005];
lli b[505][505];
lli tot=1e18;
map<lli,lli> vis;
string s1="\0";
string s2="\0";
string s;
string ss;
lli f=0;
map<ll,lli> ml;
int ff;
void dfs(lli i,lli mi,lli root)
{
    vis[i]=1;
    if(v[i].size()==0)
    {
        vv.push_back({root,i,mi});
        ff=1;
        return;
    }
    for(int j=0;j<v[i].size();j++)
    {
        if(vis[v[i][j].first]==0)
        {
            lli d=min(mi,v[i][j].second);
            dfs(v[i][j].first,d,root);
        }
    }
}
lli aa(string s)
{
    lli cnt=0;
    lli ans=0;
    for(int j=0;j<s.length();j++)
    {
        if(s[j]>'0')
        {
            if(s[j]>'1')
            {
            for(int hh=0;hh<=3-cnt-1;hh++)
            {
            if(hh==0)
            ans+=(s[j]-'0')-1;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*(k)*9;
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*((k*(k-1))/2)*9*9;
            }
            }
            }
            for(int hh=0;hh<=3-cnt;hh++)
            {
            if(hh==0)
            ans++;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((k)*9);
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+(((k*(k-1))/2)*9*9);
            }
            else
            {
                lli k=s.length()-j-1;
            ans=ans+(((k*(k-1)*(k-2))/6)*9*9*9);
            }
            //cout<<hh<<" "<<j+1<<" "<<ans<<endl;
            }
            //ans+=
            cnt++;
        }
    }
    return ans;
}
map<lli,lli> dp,dp1;
int main()
{
cin>>n;
queue<lli> q;
deque<lli> d;
stack<lli> s;
lli x;
for(int i=1;i<=n;i++)
{
    cin>>x;
    if(x==0)
    {
        if(s.empty()&&q.empty()&&d.empty())
        cout<<0;
        else
        {
            multimap<lli,string,greater<lli>> ml;
            if(!s.empty())
            {
                ml.insert({s.top(),"popStack"});
            }
            if(!q.empty())
            ml.insert({q.front(),"popQueue"});
            if(!d.empty())
            {
                if(d.size()>1)
                ml.insert({d.front(),"popFront"}),ml.insert({d.back(),"popBack"});
                else
                ml.insert({d.front(),"popFront"});
            }
            lli cnt=1;
            lli ms=ml.size();
            ms=min(ms,3ll);
            cout<<ms<<" ";
            for(auto &i: ml)
            {
                if(cnt<=3)
                {
                    if(cnt<ms)
                    cout<<i.second<<" ";
                    else
                    cout<<i.second;
                    if(i.second=="popStack")
                    s.pop();
                    else if(i.second=="popQueue")
                    q.pop();
                    else if(i.second=="popFront")
                    d.pop_front();
                    else
                    d.pop_back();
                }
                cnt++;
            }
            ml.clear();
        }
    }
    else
    {
        if(s.empty())
        {
            s.push(x);
            cout<<"pushStack";
        }
        else if(q.empty())
        {
            q.push(x);
            cout<<"pushQueue";
        }
        else if(d.size()<=1)
        {
            d.push_front(x);
            cout<<"pushFront";
        }
        else
        {
            multimap<lli,string> ml;
            ml.insert({s.top(),"pushStack"});
            ml.insert({q.front(),"pushQueue"});
            ml.insert({d.front(),"pushFront"});
            ml.insert({d.back(),"pushBack"});
            string ss=ml.begin()->second;
            if(ss=="pushStack")
            {
                cout<<ss;
                s.push(x);
            }
            else if(ss=="pushQueue")
            {
                cout<<ss;
                q.push(x);
            }
            else if(ss=="pushFront")
            {
                cout<<ss;
                d.push_front(x);
            }
            else
            {
                cout<<ss;
                d.push_back(x);
            }
            ml.clear();
        }
    }
}
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,m,t,q,z;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
unordered_map<lli,lli> mm,mm1,mm2;
struct edge
{
    lli first,second,third;
};
vector<edge> vv;

vector<ll> v[200005];
//set<lli> s;
map<lli,lli> mk;
//int f=0;
map<ll,lli> bb;
//lli mx=-1;
//lli a[200005];
lli mi=1e18;
ll p[200005];
lli mx=1;
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d,fl;
map<ll,lli> allow;
lli a[100005];
lli b[505][505];
lli tot=1e18;
map<lli,lli> vis;
string s1="\0";
string s2="\0";
string s;
string ss;
lli f=0;
map<ll,lli> ml;
int ff;
void dfs(lli i,lli mi,lli root)
{
    vis[i]=1;
    if(v[i].size()==0)
    {
        vv.push_back({root,i,mi});
        ff=1;
        return;
    }
    for(int j=0;j<v[i].size();j++)
    {
        if(vis[v[i][j].first]==0)
        {
            lli d=min(mi,v[i][j].second);
            dfs(v[i][j].first,d,root);
        }
    }
}
lli aa(string s)
{
    lli cnt=0;
    lli ans=0;
    for(int j=0;j<s.length();j++)
    {
        if(s[j]>'0')
        {
            if(s[j]>'1')
            {
            for(int hh=0;hh<=3-cnt-1;hh++)
            {
            if(hh==0)
            ans+=(s[j]-'0')-1;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*(k)*9;
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*((k*(k-1))/2)*9*9;
            }
            }
            }
            for(int hh=0;hh<=3-cnt;hh++)
            {
            if(hh==0)
            ans++;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((k)*9);
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+(((k*(k-1))/2)*9*9);
            }
            else
            {
                lli k=s.length()-j-1;
            ans=ans+(((k*(k-1)*(k-2))/6)*9*9*9);
            }
            //cout<<hh<<" "<<j+1<<" "<<ans<<endl;
            }
            //ans+=
            cnt++;
        }
    }
    return ans;
}
map<lli,lli> dp,dp1;
int main()
{
cin>>n;
queue<lli> q;
deque<lli> d;
stack<lli> s;
lli x;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
}
for(int i=1;i<=n;i++)
{
    x=a[i];
    if(x==0)
    {
        if(s.empty()&&q.empty()&&d.empty())
        cout<<"0\n";
        else
        {
            multimap<lli,string,greater<lli>> ml;
            if(!s.empty())
            {
                ml.insert({s.top(),"popStack"});
            }
            if(!q.empty())
            ml.insert({q.front(),"popQueue"});
            if(!d.empty())
            {
                if(d.size()>1)
                ml.insert({d.front(),"popFront"}),ml.insert({d.back(),"popBack"});
                else
                ml.insert({d.front(),"popFront"});
            }
            lli cnt=1;
            lli ms=ml.size();
            ms=min(ms,3ll);
            cout<<min(ms,3ll)<<" ";
            for(auto &i: ml)
            {
                if(cnt<=3)
                {
                    if(cnt<ms)
                    cout<<i.second<<" ";
                    else
                    cout<<i.second;
                    if(i.second=="popStack")
                    s.pop();
                    else if(i.second=="popQueue")
                    q.pop();
                    else if(i.second=="popFront")
                    d.pop_front();
                    else
                    d.pop_back();
                }
                cnt++;
            }
            cout<<"\n";
            ml.clear();
        }
    }
    else
    {
        if(s.empty())
        {
            s.push(x);
            cout<<"pushStack\n";
        }
        else if(q.empty())
        {
            q.push(x);
            cout<<"pushQueue\n";
        }
        else if(d.size()<=1)
        {
            d.push_front(x);
            cout<<"pushFront\n";
        }
        else
        {
            multimap<lli,string> ml;
            ml.insert({s.top(),"pushStack"});
            ml.insert({q.front(),"pushQueue"});
            ml.insert({d.front(),"pushFront"});
            ml.insert({d.back(),"pushBack"});
            string ss=ml.begin()->second;
            if(ss=="pushStack")
            {
                cout<<ss<<"\n";
                s.push(x);
            }
            else if(ss=="pushQueue")
            {
                cout<<ss<<"\n";
                q.push(x);
            }
            else if(ss=="pushFront")
            {
                cout<<ss<<"\n";
                d.push_front(x);
            }
            else
            {
                cout<<ss<<"\n";
                d.push_back(x);
            }
            ml.clear();
        }
    }
}
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,m,t,q,z;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
unordered_map<lli,lli> mm,mm1,mm2;
struct edge
{
    lli first,second,third;
};
vector<edge> vv;

vector<ll> v[200005];
//set<lli> s;
map<lli,lli> mk;
//int f=0;
map<ll,lli> bb;
//lli mx=-1;
//lli a[200005];
lli mi=1e18;
ll p[200005];
lli mx=1;
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d,fl;
map<ll,lli> allow;
lli a[100005];
lli b[505][505];
lli tot=1e18;
map<lli,lli> vis;
string s1="\0";
string s2="\0";
string s;
string ss;
lli f=0;
map<ll,lli> ml;
int ff;
void dfs(lli i,lli mi,lli root)
{
    vis[i]=1;
    if(v[i].size()==0)
    {
        vv.push_back({root,i,mi});
        ff=1;
        return;
    }
    for(int j=0;j<v[i].size();j++)
    {
        if(vis[v[i][j].first]==0)
        {
            lli d=min(mi,v[i][j].second);
            dfs(v[i][j].first,d,root);
        }
    }
}
lli aa(string s)
{
    lli cnt=0;
    lli ans=0;
    for(int j=0;j<s.length();j++)
    {
        if(s[j]>'0')
        {
            if(s[j]>'1')
            {
            for(int hh=0;hh<=3-cnt-1;hh++)
            {
            if(hh==0)
            ans+=(s[j]-'0')-1;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*(k)*9;
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*((k*(k-1))/2)*9*9;
            }
            }
            }
            for(int hh=0;hh<=3-cnt;hh++)
            {
            if(hh==0)
            ans++;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((k)*9);
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+(((k*(k-1))/2)*9*9);
            }
            else
            {
                lli k=s.length()-j-1;
            ans=ans+(((k*(k-1)*(k-2))/6)*9*9*9);
            }
            //cout<<hh<<" "<<j+1<<" "<<ans<<endl;
            }
            //ans+=
            cnt++;
        }
    }
    return ans;
}
map<lli,lli> dp,dp1;
int main()
{
cin>>n;
queue<lli> q;
deque<lli> d;
stack<lli> s;
lli x;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
}
for(int i=1;i<=n;i++)
{
    x=a[i];
    if(x==0)
    {
        if(s.empty()&&q.empty()&&d.empty())
        cout<<"0\n";
        else
        {
            multimap<lli,string,greater<lli>> ml;
            if(!s.empty())
            {
                ml.insert({s.top(),"popStack"});
            }
            if(!q.empty())
            ml.insert({q.front(),"popQueue"});
            if(!d.empty())
            {
                if(d.size()>1)
                {
                    if(d.front()>d.back())
                    ml.insert({d.front(),"popFront"});
                    else
                    ml.insert({d.back(),"popBack"});
                }
                else
                ml.insert({d.front(),"popFront"});
            }
            lli cnt=1;
            lli ms=ml.size();
            ms=min(ms,3ll);
            cout<<min(ms,3ll)<<" ";
            for(auto &i: ml)
            {
                if(cnt<=3)
                {
                    if(cnt<ms)
                    cout<<i.second<<" ";
                    else
                    cout<<i.second;
                    if(i.second=="popStack")
                    s.pop();
                    else if(i.second=="popQueue")
                    q.pop();
                    else if(i.second=="popFront")
                    d.pop_front();
                    else
                    d.pop_back();
                }
                cnt++;
            }
            cout<<"\n";
            ml.clear();
        }
    }
    else
    {
        if(s.empty())
        {
            s.push(x);
            cout<<"pushStack\n";
        }
        else if(q.empty())
        {
            q.push(x);
            cout<<"pushQueue\n";
        }
        else if(d.size()<=1)
        {
            d.push_front(x);
            cout<<"pushFront\n";
        }
        else
        {
            multimap<lli,string> ml;
            ml.insert({s.top(),"pushStack"});
            ml.insert({q.front(),"pushQueue"});
            ml.insert({d.front(),"pushFront"});
            ml.insert({d.back(),"pushBack"});
            string ss=ml.begin()->second;
            if(ss=="pushStack")
            {
                cout<<ss<<"\n";
                s.push(x);
            }
            else if(ss=="pushQueue")
            {
                cout<<ss<<"\n";
                q.push(x);
            }
            else if(ss=="pushFront")
            {
                cout<<ss<<"\n";
                d.push_front(x);
            }
            else
            {
                cout<<ss<<"\n";
                d.push_back(x);
            }
            ml.clear();
        }
    }
}
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,m,t,q,z;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
unordered_map<lli,lli> mm,mm1,mm2;
struct edge
{
    lli first,second,third;
};
vector<edge> vv;

vector<ll> v[200005];
//set<lli> s;
map<lli,lli> mk;
//int f=0;
map<ll,lli> bb;
//lli mx=-1;
//lli a[200005];
lli mi=1e18;
ll p[200005];
lli mx=1;
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d,fl;
map<ll,lli> allow;
lli a[100005];
lli b[505][505];
lli tot=1e18;
map<lli,lli> vis;
string s1="\0";
string s2="\0";
string s;
string ss;
lli f=0;
map<ll,lli> ml;
int ff;
void dfs(lli i,lli mi,lli root)
{
    vis[i]=1;
    if(v[i].size()==0)
    {
        vv.push_back({root,i,mi});
        ff=1;
        return;
    }
    for(int j=0;j<v[i].size();j++)
    {
        if(vis[v[i][j].first]==0)
        {
            lli d=min(mi,v[i][j].second);
            dfs(v[i][j].first,d,root);
        }
    }
}
lli aa(string s)
{
    lli cnt=0;
    lli ans=0;
    for(int j=0;j<s.length();j++)
    {
        if(s[j]>'0')
        {
            if(s[j]>'1')
            {
            for(int hh=0;hh<=3-cnt-1;hh++)
            {
            if(hh==0)
            ans+=(s[j]-'0')-1;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*(k)*9;
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*((k*(k-1))/2)*9*9;
            }
            }
            }
            for(int hh=0;hh<=3-cnt;hh++)
            {
            if(hh==0)
            ans++;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((k)*9);
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+(((k*(k-1))/2)*9*9);
            }
            else
            {
                lli k=s.length()-j-1;
            ans=ans+(((k*(k-1)*(k-2))/6)*9*9*9);
            }
            //cout<<hh<<" "<<j+1<<" "<<ans<<endl;
            }
            //ans+=
            cnt++;
        }
    }
    return ans;
}
map<lli,lli> dp,dp1;
int main()
{
cin>>n;
queue<lli> q;
deque<lli> d;
stack<lli> s;
lli x;
multiset<ll,greater<ll>> mm;
map<lli,string> nn;
map<string,lli> kl;
lli kk=1;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]>0)
    {
        mm.insert({a[i],i});
    }
    else
    {
        lli stack=0;
        lli queue=0;
        lli deck=0;
        vector<ll> ee;
        for(auto &j : mm)
        {
            if(kk<=3)
            {
            if(stack==deck)
            nn[j.second]="pushStack",stack++,ee.push_back({j.first,j.second});
            else if(queue==deck)
            nn[j.second]="pushQueue",queue++,ee.push_back({j.first,j.second});
            else
            {
                nn[j.second]="pushFront";
                deck++;
                ee.push_back({j.first,j.second});
            }
            kk++;
            }
        }
        for(int j=0;j<ee.size();j++)
        {
            mm.erase(mm.find(ee[j]));
        }
        ee.clear();
        if(stack>0)
        stack--;
        if(queue>0)
        queue--;
        if(deck>0)
        deck--;
        kk=1;
    }
}
for(int i=1;i<=n;i++)
{
    if(a[i]>0)
    {
        if(nn.find(i)!=nn.end())
        {
            cout<<nn[i]<<"\n";
            kl[nn[i]]++;
        }
        else
        cout<<"pushBack\n";
    }
    else
    {
        vector<string> cv;
        if(kl["pushStack"]>0)
        cv.push_back("popStack"),kl["pushStack"]--;
        if(kl["pushQueue"]>0)
        cv.push_back("popQueue"),kl["pushQueue"]--;
        if(kl["pushFront"]>0)
        cv.push_back("popFront"),kl["pushFront"]--;
        if(cv.size()==0)
        cout<<cv.size();
        else
        cout<<cv.size()<<" ";
        for(int j=0;j<cv.size();j++)
        {
            if(j==cv.size()-1)
            cout<<cv[j];
            else
            cout<<cv[j]<<" ";
        }
        cout<<"\n";
    }
}
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,m,t,q,z;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
unordered_map<lli,lli> mm,mm1,mm2;
struct edge
{
    lli first,second,third;
};
vector<edge> vv;

vector<ll> v[200005];
//set<lli> s;
map<lli,lli> mk;
//int f=0;
map<ll,lli> bb;
//lli mx=-1;
//lli a[200005];
lli mi=1e18;
ll p[200005];
lli mx=1;
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d,fl;
map<ll,lli> allow;
lli a[100005];
lli b[505][505];
lli tot=1e18;
map<lli,lli> vis;
string s1="\0";
string s2="\0";
string s;
string ss;
lli f=0;
map<ll,lli> ml;
int ff;
void dfs(lli i,lli mi,lli root)
{
    vis[i]=1;
    if(v[i].size()==0)
    {
        vv.push_back({root,i,mi});
        ff=1;
        return;
    }
    for(int j=0;j<v[i].size();j++)
    {
        if(vis[v[i][j].first]==0)
        {
            lli d=min(mi,v[i][j].second);
            dfs(v[i][j].first,d,root);
        }
    }
}
lli aa(string s)
{
    lli cnt=0;
    lli ans=0;
    for(int j=0;j<s.length();j++)
    {
        if(s[j]>'0')
        {
            if(s[j]>'1')
            {
            for(int hh=0;hh<=3-cnt-1;hh++)
            {
            if(hh==0)
            ans+=(s[j]-'0')-1;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*(k)*9;
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*((k*(k-1))/2)*9*9;
            }
            }
            }
            for(int hh=0;hh<=3-cnt;hh++)
            {
            if(hh==0)
            ans++;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((k)*9);
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+(((k*(k-1))/2)*9*9);
            }
            else
            {
                lli k=s.length()-j-1;
            ans=ans+(((k*(k-1)*(k-2))/6)*9*9*9);
            }
            //cout<<hh<<" "<<j+1<<" "<<ans<<endl;
            }
            //ans+=
            cnt++;
        }
    }
    return ans;
}
map<lli,lli> dp,dp1;
int main()
{
cin>>n;
queue<lli> q;
deque<lli> d;
stack<lli> s;
lli x;
multiset<lli,greater<lli>> mm;
lli cnt=0;
lli tot=1;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]>0)
    {}//mm.insert(a[i]);
    else
    cnt++;
}
for(int i=1;i<=n;i++)
{
    if(a[i]>0&&tot<=3*cnt)
    mm.insert(a[i]),tot++;
}
lli front=0;
lli level=1;
lli kk=1;
for(int i=1;i<=n;i++)
{
    if(a[i]>0&&mm.count(a[i])>0)
    {
        if(kk==1)
        {
            cout<<"pushStack\n";
            s.push(a[i]);
            kk++;
        }
        else if(kk==2)
        {
            cout<<"pushQueue\n";
            q.push(a[i]);
            kk++;
        }
        else if(kk==3)
        {
            cout<<"pushFront\n";
            d.push_front(a[i]);
            kk++;
            front++;
        }
        if(kk==4)
        {
            kk=1;
            //level++;
        }
    }
    else if(a[i]>0)
    {
        cout<<"pushBack\n";
        d.push_back(a[i]);
    }
    else
    {
        map<string,lli> ms;
        lli op=0;
        while(!s.empty())
        {
            if(op<1)
            {
            ms["popStack"]++;
            op++;
            s.pop();
            }
            else
            break;
        }
        while(!q.empty())
        {
            if(op<2)
            {
            ms["popQueue"]++;
            op++;
            q.pop();
            }
            else
            break;
        }
        while(!d.empty())
        {
            if(op<3)
            {
            ms["popFront"]++;
            op++;
            d.pop_front();
            }
            else
            break;
        }
        if(op>0)
        cout<<op<<" ";
        else
        cout<<op;
        for(auto &i:ms)
        {
            if(op>1)
            cout<<i.first<<" ",op--;
            else
            cout<<i.first,op--;
        }
        cout<<"\n";
        kk=1;
    }
}
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,m,t,q,z;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
unordered_map<lli,lli> mm,mm1,mm2;
struct edge
{
    lli first,second,third;
};
vector<edge> vv;

vector<ll> v[200005];
//set<lli> s;
map<lli,lli> mk;
//int f=0;
map<ll,lli> bb;
//lli mx=-1;
//lli a[200005];
lli mi=1e18;
ll p[200005];
lli mx=1;
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d,fl;
map<ll,lli> allow;
lli a[100005];
lli b[505][505];
lli tot=1e18;
map<lli,lli> vis;
string s1="\0";
string s2="\0";
string s;
string ss;
lli f=0;
map<ll,lli> ml;
int ff;
void dfs(lli i,lli mi,lli root)
{
    vis[i]=1;
    if(v[i].size()==0)
    {
        vv.push_back({root,i,mi});
        ff=1;
        return;
    }
    for(int j=0;j<v[i].size();j++)
    {
        if(vis[v[i][j].first]==0)
        {
            lli d=min(mi,v[i][j].second);
            dfs(v[i][j].first,d,root);
        }
    }
}
lli aa(string s)
{
    lli cnt=0;
    lli ans=0;
    for(int j=0;j<s.length();j++)
    {
        if(s[j]>'0')
        {
            if(s[j]>'1')
            {
            for(int hh=0;hh<=3-cnt-1;hh++)
            {
            if(hh==0)
            ans+=(s[j]-'0')-1;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*(k)*9;
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*((k*(k-1))/2)*9*9;
            }
            }
            }
            for(int hh=0;hh<=3-cnt;hh++)
            {
            if(hh==0)
            ans++;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((k)*9);
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+(((k*(k-1))/2)*9*9);
            }
            else
            {
                lli k=s.length()-j-1;
            ans=ans+(((k*(k-1)*(k-2))/6)*9*9*9);
            }
            //cout<<hh<<" "<<j+1<<" "<<ans<<endl;
            }
            //ans+=
            cnt++;
        }
    }
    return ans;
}
map<lli,lli> dp,dp1;
int main()
{
cin>>n;
queue<lli> q;
deque<lli> d;
stack<lli> s;
lli x;
multiset<ll,greater<ll>> mm;
map<lli,string> nn;
map<string,lli> kl;
lli kk=1;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]>0)
    {
        mm.insert({a[i],i});
    }
    else
    {
        lli stack=0;
        lli queue=0;
        lli deck=0;
        vector<ll> ee;
        for(auto &j : mm)
        {

            if(stack==deck)
            nn[j.second]="pushStack",stack++,ee.push_back({j.first,j.second});
            else if(queue==deck)
            nn[j.second]="pushQueue",queue++,ee.push_back({j.first,j.second});
            else
            {
                nn[j.second]="pushFront";
                deck++;
                ee.push_back({j.first,j.second});
                break;
            }
        }
        for(int j=0;j<ee.size();j++)
        {
            mm.erase(mm.find(ee[j]));
        }
        ee.clear();
        //if(kk==4)
        kk=1;
    }
}
for(int i=1;i<=n;i++)
{
    if(a[i]>0)
    {
        if(nn.find(i)!=nn.end())
        {
            cout<<nn[i]<<"\n";
            kl[nn[i]]++;
        }
        else
        cout<<"pushBack\n";
    }
    else
    {
        vector<string> cv;
        if(kl["pushStack"]>0)
        cv.push_back("popStack"),kl["pushStack"]--;
        if(kl["pushQueue"]>0)
        cv.push_back("popQueue"),kl["pushQueue"]--;
        if(kl["pushFront"]>0)
        cv.push_back("popFront"),kl["pushFront"]--;
        if(cv.size()==0)
        cout<<cv.size();
        else
        cout<<cv.size()<<" ";
        for(int j=0;j<cv.size();j++)
        {
            if(j==cv.size()-1)
            cout<<cv[j];
            else
            cout<<cv[j]<<" ";
        }
        cout<<"\n";
    }
}
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,m,t,q,z;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
unordered_map<lli,lli> mm,mm1,mm2;
struct edge
{
    lli first,second,third;
};
vector<edge> vv;

vector<ll> v[200005];
//set<lli> s;
map<lli,lli> mk;
//int f=0;
map<ll,lli> bb;
//lli mx=-1;
//lli a[200005];
lli mi=1e18;
ll p[200005];
lli mx=1;
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d,fl;
map<ll,lli> allow;
lli a[100005];
lli b[505][505];
lli tot=1e18;
map<lli,lli> vis;
string s1="\0";
string s2="\0";
string s;
string ss;
lli f=0;
map<ll,lli> ml;
int ff;
void dfs(lli i,lli mi,lli root)
{
    vis[i]=1;
    if(v[i].size()==0)
    {
        vv.push_back({root,i,mi});
        ff=1;
        return;
    }
    for(int j=0;j<v[i].size();j++)
    {
        if(vis[v[i][j].first]==0)
        {
            lli d=min(mi,v[i][j].second);
            dfs(v[i][j].first,d,root);
        }
    }
}
lli aa(string s)
{
    lli cnt=0;
    lli ans=0;
    for(int j=0;j<s.length();j++)
    {
        if(s[j]>'0')
        {
            if(s[j]>'1')
            {
            for(int hh=0;hh<=3-cnt-1;hh++)
            {
            if(hh==0)
            ans+=(s[j]-'0')-1;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*(k)*9;
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*((k*(k-1))/2)*9*9;
            }
            }
            }
            for(int hh=0;hh<=3-cnt;hh++)
            {
            if(hh==0)
            ans++;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((k)*9);
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+(((k*(k-1))/2)*9*9);
            }
            else
            {
                lli k=s.length()-j-1;
            ans=ans+(((k*(k-1)*(k-2))/6)*9*9*9);
            }
            //cout<<hh<<" "<<j+1<<" "<<ans<<endl;
            }
            //ans+=
            cnt++;
        }
    }
    return ans;
}
map<lli,lli> dp,dp1;
int main()
{
cin>>n;
queue<lli> q;
deque<lli> d;
stack<lli> s;
lli x;
multiset<ll,greater<ll>> mm;
map<lli,string> nn;
map<string,lli> kl;
lli kk=1;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]>0)
    {
        mm.insert({a[i],i});
    }
    else
    {
        lli stack=0;
        lli queue=0;
        lli deck=0;
        vector<ll> ee;
        for(auto &j : mm)
        {
            if(kk<=3)
            {
            if(stack==deck)
            nn[j.second]="pushStack",stack++,ee.push_back({j.first,j.second});
            else if(queue==deck)
            nn[j.second]="pushQueue",queue++,ee.push_back({j.first,j.second});
            else
            {
                nn[j.second]="pushFront";
                deck++;
                ee.push_back({j.first,j.second});
                break;
            }
            kk++;
            }
        }
        for(int j=0;j<ee.size();j++)
        {
            mm.erase(mm.find(ee[j]));
        }
        ee.clear();
        if(stack>0)
        stack--;
        if(queue>0)
        queue--;
        if(deck>0)
        deck--;
        //if(kk==4)
        kk=1;
    }
}
for(int i=1;i<=n;i++)
{
    if(a[i]>0)
    {
        if(nn.find(i)!=nn.end())
        {
            cout<<nn[i]<<"\n";
            kl[nn[i]]++;
        }
        else
        cout<<"pushBack\n";
    }
    else
    {
        vector<string> cv;
        if(kl["pushStack"]>0)
        cv.push_back("popStack"),kl["pushStack"]--;
        if(kl["pushQueue"]>0)
        cv.push_back("popQueue"),kl["pushQueue"]--;
        if(kl["pushFront"]>0)
        cv.push_back("popFront"),kl["pushFront"]--;
        if(cv.size()==0)
        cout<<cv.size();
        else
        cout<<cv.size()<<" ";
        for(int j=0;j<cv.size();j++)
        {
            if(j==cv.size()-1)
            cout<<cv[j];
            else
            cout<<cv[j]<<" ";
        }
        cout<<"\n";
    }
}
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,m,t,q,z;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
unordered_map<lli,lli> mm,mm1,mm2;
struct edge
{
    lli first,second,third;
};
vector<edge> vv;

vector<ll> v[200005];
//set<lli> s;
map<lli,lli> mk;
//int f=0;
map<ll,lli> bb;
//lli mx=-1;
//lli a[200005];
lli mi=1e18;
ll p[200005];
lli mx=1;
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d,fl;
map<ll,lli> allow;
lli a[100005];
lli b[505][505];
lli tot=1e18;
map<lli,lli> vis;
string s1="\0";
string s2="\0";
string s;
string ss;
lli f=0;
map<ll,lli> ml;
int ff;
void dfs(lli i,lli mi,lli root)
{
    vis[i]=1;
    if(v[i].size()==0)
    {
        vv.push_back({root,i,mi});
        ff=1;
        return;
    }
    for(int j=0;j<v[i].size();j++)
    {
        if(vis[v[i][j].first]==0)
        {
            lli d=min(mi,v[i][j].second);
            dfs(v[i][j].first,d,root);
        }
    }
}
lli aa(string s)
{
    lli cnt=0;
    lli ans=0;
    for(int j=0;j<s.length();j++)
    {
        if(s[j]>'0')
        {
            if(s[j]>'1')
            {
            for(int hh=0;hh<=3-cnt-1;hh++)
            {
            if(hh==0)
            ans+=(s[j]-'0')-1;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*(k)*9;
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*((k*(k-1))/2)*9*9;
            }
            }
            }
            for(int hh=0;hh<=3-cnt;hh++)
            {
            if(hh==0)
            ans++;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((k)*9);
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+(((k*(k-1))/2)*9*9);
            }
            else
            {
                lli k=s.length()-j-1;
            ans=ans+(((k*(k-1)*(k-2))/6)*9*9*9);
            }
            //cout<<hh<<" "<<j+1<<" "<<ans<<endl;
            }
            //ans+=
            cnt++;
        }
    }
    return ans;
}
map<lli,lli> dp,dp1;
int main()
{
cin>>n;
queue<lli> q;
deque<lli> d;
stack<lli> s;
lli x;
multimap<lli,lli,greater<lli>> mm;
map<lli,string> nn;
map<string,lli> kl;
lli kk=1;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]>0)
    {
        mm.insert({a[i],i});
    }
    else
    {
        lli stack=0;
        lli queue=0;
        lli deck=0;
        vector<lli> ee;
        for(auto &j : mm)
        {
            if(kk<=3)
            {
            if(stack==deck)
            nn[j.second]="pushStack",stack++,ee.push_back(j.first);
            else if(queue==deck)
            nn[j.second]="pushQueue",queue++,ee.push_back(j.first);
            else
            {
                nn[j.second]="pushFront";
                deck++;
                ee.push_back(j.first);
            }
            kk++;
            }
        }
        for(int j=0;j<ee.size();j++)
        {
            mm.erase(mm.find(ee[j]));
        }
        ee.clear();
        if(stack>0)
        stack--;
        if(queue>0)
        queue--;
        if(deck>0)
        deck--;
        kk=1;
    }
}
for(int i=1;i<=n;i++)
{
    if(a[i]>0)
    {
        if(nn.find(i)!=nn.end())
        {
            cout<<nn[i]<<"\n";
            kl[nn[i]]++;
        }
        else
        cout<<"pushBack\n";
    }
    else
    {
        vector<string> cv;
        if(kl["pushStack"]>0)
        cv.push_back("popStack"),kl["pushStack"]--;
        if(kl["pushQueue"]>0)
        cv.push_back("popQueue"),kl["pushQueue"]--;
        if(kl["pushFront"]>0)
        cv.push_back("popFront"),kl["pushFront"]--;
        if(cv.size()==0)
        cout<<cv.size();
        else
        cout<<cv.size()<<" ";
        for(int j=0;j<cv.size();j++)
        {
            if(j==cv.size()-1)
            cout<<cv[j];
            else
            cout<<cv[j]<<" ";
        }
        cout<<"\n";
    }
}
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,m,t,q,z;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
unordered_map<lli,lli> mm,mm1,mm2;
struct edge
{
    lli first,second,third;
};
vector<edge> vv;

vector<ll> v[200005];
//set<lli> s;
map<lli,lli> mk;
//int f=0;
map<ll,lli> bb;
//lli mx=-1;
//lli a[200005];
lli mi=1e18;
ll p[200005];
lli mx=1;
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d,fl;
map<ll,lli> allow;
lli a[100005];
lli b[505][505];
lli tot=1e18;
map<lli,lli> vis;
string s1="\0";
string s2="\0";
string s;
string ss;
lli f=0;
map<ll,lli> ml;
int ff;
void dfs(lli i,lli mi,lli root)
{
    vis[i]=1;
    if(v[i].size()==0)
    {
        vv.push_back({root,i,mi});
        ff=1;
        return;
    }
    for(int j=0;j<v[i].size();j++)
    {
        if(vis[v[i][j].first]==0)
        {
            lli d=min(mi,v[i][j].second);
            dfs(v[i][j].first,d,root);
        }
    }
}
lli aa(string s)
{
    lli cnt=0;
    lli ans=0;
    for(int j=0;j<s.length();j++)
    {
        if(s[j]>'0')
        {
            if(s[j]>'1')
            {
            for(int hh=0;hh<=3-cnt-1;hh++)
            {
            if(hh==0)
            ans+=(s[j]-'0')-1;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*(k)*9;
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+((s[j]-'0')-1)*((k*(k-1))/2)*9*9;
            }
            }
            }
            for(int hh=0;hh<=3-cnt;hh++)
            {
            if(hh==0)
            ans++;
            else if(hh==1)
            {
                lli k=s.length()-j-1;
                ans=ans+((k)*9);
            }
            else if(hh==2)
            {
                 lli k=s.length()-j-1;
                ans=ans+(((k*(k-1))/2)*9*9);
            }
            else
            {
                lli k=s.length()-j-1;
            ans=ans+(((k*(k-1)*(k-2))/6)*9*9*9);
            }
            //cout<<hh<<" "<<j+1<<" "<<ans<<endl;
            }
            //ans+=
            cnt++;
        }
    }
    return ans;
}
map<lli,lli> dp,dp1;
int main()
{
cin>>n;
queue<lli> q;
deque<lli> d;
stack<lli> s;
lli x;
multiset<lli,greater<lli>> mm,mr;
lli cnt=0;
lli tot=1;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]>0)
    mr.insert(a[i]);
    else
    cnt++;
}
for(auto &i : mr)
{
    if(i>0&&tot<=3*cnt)
    mm.insert(i),tot++;
}
lli front=0;
lli level=1;
lli kk=1;
for(int i=1;i<=n;i++)
{
    if(a[i]>0&&mm.count(a[i])>0)
    {
        if(kk==1)
        {
            cout<<"pushStack\n";
            s.push(a[i]);
            kk++;
        }
        else if(kk==2)
        {
            cout<<"pushQueue\n";
            q.push(a[i]);
            kk++;
        }
        else if(kk==3)
        {
            cout<<"pushFront\n";
            d.push_front(a[i]);
            kk++;
            front++;
        }
        if(kk==4)
        {
            kk=1;
            //level++;
        }
    }
    else if(a[i]>0)
    {
        cout<<"pushBack\n";
        d.push_back(a[i]);
    }
    else
    {
        map<string,lli> ms;
        lli op=0;
        while(!s.empty())
        {
            if(op<1)
            {
            ms["popStack"]++;
            op++;
            s.pop();
            }
            else
            break;
        }
        while(!q.empty())
        {
            if(op<2)
            {
            ms["popQueue"]++;
            op++;
            q.pop();
            }
            else
            break;
        }
        while(front>0)
        {
            if(op<3)
            {
            ms["popFront"]++;
            op++;
            d.pop_front();
            front--;
            }
            else
            break;
        }
        if(op>0)
        cout<<op<<" ";
        else
        cout<<op;
        for(auto &i:ms)
        {
            if(op>1&&i.second>0)
            cout<<i.first<<" ",op--;
            else if(i.second>0)
            cout<<i.first,op--;
        }
        cout<<"\n";
        kk=1;
    }
}
}


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    long long int n,*a,max=0,min,mxpos=0,mnpos=0,t,i;
    scanf("%lld",&n);
    a=(long long int *)malloc(sizeof(long long int) * n);
    for(i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
        if(i==0)
        {
            min=a[i];
        }
        if(max<=a[i])
        {
            max=a[i];
        }
        if(min>=a[i])
        {
            min=a[i];
        }
    }
    for(i=0; i<n; i++)
    {
        if(max==a[i])
        {
            mxpos++;
        }
        if(min==a[i])
        {
            mnpos++;
        }
    }
    if(max==min)
    {
        printf("%lld %lld\n",max-min,(n*(n-1))/2);
    }
    else
    {
        printf("%lld %lld\n",max-min,mxpos*mnpos);
    }
    return 0;
}


#include <stdio.h>

int main()
{
  long long  a[200001]={0},min=999999999,max=1,n,i,x,mincount=0,maxcount=0;
  scanf("%I64d",&n);
  for (i=0;i<n;i++){
    scanf("%I64d",&x);
    a[x]++;
    if (x<min){
      mincount=0;
      min=x;
    }
    if (x==min)
      mincount++;
    if (x>max){
      maxcount=0;
      max=x;
    }
    if (x==max)
      maxcount++;
  }
  printf("%I64d %I64d\n",max-min,maxcount*mincount);
  return 0;
}


#include <stdio.h>

int main()
{
  int a[200001]={0},min=999999999,max=1,n,i,x,mincount=0,maxcount=0;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&x);
    a[x]++;
    if (x<min){
      mincount=0;
      min=x;
    }
    if (x==min)
      mincount++;
    if (x>max){
      maxcount=0;
      max=x;
    }
    if (x==max)
      maxcount++;
  }
  printf("%d %d\n",max-min,maxcount*mincount);
  return 0;
}


#include <stdio.h>

int main()
{
  long long  a[200001]={0},min=999999999,max=1,n,i,x,mincount=0,maxcount=0;
  scanf("%I64d",&n);
  for (i=0;i<n;i++){
    scanf("%I64d",&x);
    a[x]++;
    if (x<min){
      mincount=0;
      min=x;
    }
    if (x==min)
      mincount++;
    if (x>max){
      maxcount=0;
      max=x;
    }
    if (x==max)
      maxcount++;
  }
  if (min!=max)
    printf("%I64d %I64d\n",max-min,maxcount*mincount);
  else
    printf("%I64d %I64d\n",max-min,(maxcount*(maxcount-1))/2);
  return 0;
}


#include <stdio.h>

int main()
{
  long long  a[200001]={0},min=999999999,max=1,n,i,x,mincount=0,maxcount=0;
  scanf("%I64d",&n);
  for (i=0;i<n;i++){
    scanf("%I64d",&x);
    a[x]++;
    if (x<min){
      mincount=0;
      min=x;
    }
    if (x==min)
      mincount++;
    if (x>max){
      maxcount=0;
      max=x;
    }
    if (x==max)
      maxcount++;
  }
  if (min!=max)
    printf("%I64d %I64d\n",max-min,maxcount*mincount);
  else
    printf("%I64d %I64d\n",max-min,maxcount);
  return 0;
}


#include <stdio.h>

int main()
{
  long long  a[200001]={0},min=999999999,max=1,n,i,x,mincount=0,maxcount=0;
  scanf("%I64d",&n);
  for (i=0;i<n;i++){
    scanf("%I64d",&x);
    a[x]++;
    if (x<min){
      mincount=0;
      min=x;
    }
    if (x==min)
      mincount++;
    if (x>max){
      maxcount=0;
      max=x;
    }
    if (x==max)
      maxcount++;
  }
  if (min!=max)
    printf("%I64d %I64d\n",max-min,maxcount*mincount);
  else
    printf("%I64d %I64d\n",max-min,(maxcount/2)*(maxcount/2-1));
  return 0;
}


#include <stdio.h>

int main()
{
  int a[200001]={0},min=999999999,max=1,n,i,x,mincount=0,maxcount=0;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&x);
    a[x]++;
    if (x<min)
      min=x;
    if (x>max)
      max=x;
  }
  printf("%d %d\n",max-min,a[min]*a[max]);
  return 0;
}


#include <stdio.h>

int swap(int *x, int *y)
{
  int z;
  z=*x;
  *x=*y;
  *y=z;
  return 0;
}

int main()
{
  int a[200001],n,b[101],i,j,max,min,mincount=0,maxcount=0;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for (i=0;i<n;i++){
    for (j=n-1;j>i;j--){
      if (a[j]<a[j-1])
	swap(&a[j],&a[j-1]);
    }
  }
  max=a[n-1];
  min=a[0];
  for (i=0;;i++){
    if (a[i]==min)
      mincount++;
    else
      break;
  }
  for (i=n-1;;i--){
    if (a[i]==max)
      maxcount++;
    else
      break;
  }
  printf("%d %d\n",max-min,mincount*maxcount);
  return 0;
}


#include <stdio.h>

int main()
{
  long long  a[200001]={0},min=999999999,max=1,n,i,x,mincount=0,maxcount=0;
  scanf("%I64d",&n);
  for (i=0;i<n;i++){
    scanf("%I64d",&x);
    a[x]++;
    if (x<min){
      mincount=0;
      min=x;
    }
    if (x==min)
      mincount++;
    if (x>max){
      maxcount=0;
      max=x;
    }
    if (x==max)
      maxcount++;
  }
  if (min!=max)
    printf("%I64d %I64d\n",max-min,maxcount*mincount);
  else
    printf("%I64d %I64d\n",max-min,(maxcount/2)*(maxcount/2-1)/2);
  return 0;
}


#include <stdio.h>

int main()
{
  long long  a[200001]={0},min=999999999,max=1,n,i,x,mincount=0,maxcount=0;
  scanf("%I64d",&n);
  for (i=0;i<n;i++){
    scanf("%I64d",&x);
    a[x]++;
    if (x<min){
      mincount=0;
      min=x;
    }
    if (x==min)
      mincount++;
    if (x>max){
      maxcount=0;
      max=x;
    }
    if (x==max && max!=min)
      maxcount++;
  }
  printf("%I64d %I64d\n",max-min,maxcount*mincount);
  return 0;
}


#include <stdio.h>

int main()
{
  long long  a[200001]={0},min=999999999,max=1,n,i,x,mincount=0,maxcount=0;
  scanf("%I64d",&n);
  for (i=0;i<n;i++){
    scanf("%I64d",&x);
    if (x<min){
      mincount=0;
      min=x;
    }
    if (x==min)
      mincount++;
    if (x>max){
      maxcount=0;
      max=x;
    }
    if (x==max)
      maxcount++;
  }
  if (min!=max)
    printf("%I64d %I64d\n",max-min,maxcount*mincount);
  else
    printf("%I64d %I64d\n",max-min,(maxcount*(maxcount-1))/2);
  return 0;
}


#include <stdio.h>

int main()
{
  long long  a[200001]={0},min=1000000000,max=1,n,i,x,mincount=0,maxcount=0;
  scanf("%I64d",&n);
  for (i=0;i<n;i++){
    scanf("%I64d",&x);
    if (x<min){
      mincount=0;
      min=x;
    }
    if (x==min)
      mincount++;
    if (x>max){
      maxcount=0;
      max=x;
    }
    if (x==max)
      maxcount++;
  }
  if (min!=max)
    printf("%I64d %I64d\n",max-min,maxcount*mincount);
  else
    printf("%I64d %I64d\n",max-min,(maxcount*(maxcount-1))/2);
  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main()
{
   int n,i,minCount=0,maxCount=0,min=INT_MAX,max=INT_MIN,num;
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
        scanf("%d",&num);
        if(min > num)
        {
            min = num;
            minCount = 0;
        }

        if(max < num)
        {
            max = num;
            maxCount = 0;
        }

        if(min == num)
        {
            minCount++;
        }
        if(max == num)
        {
            maxCount++;
        }
   }

    printf("%d %d\n",(max-min),(minCount*maxCount));
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main()
{
   int n,i,minCount=0,maxCount=0,min=INT_MAX,max=INT_MIN,num;
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
        scanf("%d",&num);
        if(min > num)
        {
            min = num;
            minCount = 1;
        }
        else if((min == num) && (min != max))
        {
            minCount++;
        }

        if(max < num)
        {
            max = num;
            if(max != min)
                maxCount = 1;
        }
        else if((max == num) && (min != max))
        {
            maxCount++;
        }
   }

    printf("%d %d\n",(max-min),(minCount*maxCount));
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main()
{
   long long int n,i,minCount=0,maxCount=0,min=INT_MAX,max=INT_MIN,num;
   scanf("%lld",&n);
   int flag = 1;
   for(i=0;i<n;i++)
   {
        scanf("%lld",&num);
        if(flag)
        {
            min=num;
            max = num;
            minCount = 1;
            maxCount=1;
            flag = 0;
        }
        else
        {
            if(min > num)
            {
                min = num;
                minCount = 1;
            }
            else if(min == num)
            {
                minCount++;
            }

            if(max < num)
            {
                max = num;
                maxCount = 1;
            }
            else if(max == num)
            {
                maxCount++;
            }
        }
   }

    if(max != min)
    {
        printf("%lld %lld\n",(max-min),(minCount*maxCount));
    }
    else
    {
        printf("0 %lld\n",(n*(n-1))/2);;
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main()
{
   long long int n,i,minCount=0,maxCount=0,min=INT_MAX,max=INT_MIN,num;
   scanf("%lld",&n);
   int flag = 1;
   for(i=0;i<n;i++)
   {
        scanf("%lld",&num);
        if(flag)
        {
            min=num;
            max = num;
            minCount = 1;
            maxCount=1;
            flag = 0;
        }
        else
        {
            if(min > num)
            {
                min = num;
                minCount = 1;
            }
            else if(min == num)
            {
                minCount++;
            }
            else if(max < num)
            {
                max = num;
                maxCount = 1;
            }
            else if(max == num)
            {
                maxCount++;
            }
        }
   }

    if(max != min)
    {
        printf("%lld %lld\n",(max-min),(minCount*maxCount));
    }
    else
    {
        printf("0 1\n");
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main()
{
   int n,i,minCount=0,maxCount=0,min=INT_MAX,max=INT_MIN,num[100000];
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
        scanf("%d",&num[i]);
        if(min > num[i])
        {
            min = num[i];
        }

        if(max < num[i])
        {
            max = num[i];
        }
   }

   for(i=0;i<n;i++)
   {
        if(min == num[i])
        {
            minCount++;
        }
        if(max == num[i])
        {
            maxCount++;
        }
   }
    printf("%d %d\n",(max-min),(minCount*maxCount));
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main()
{
   int n,i,minCount=0,maxCount=0,min=INT_MAX,max=INT_MIN,num;
   scanf("%d",&n);
   int flag = 1;
   for(i=0;i<n;i++)
   {
        scanf("%d",&num);
        if(flag)
        {
            min=num;
            max = num;
            minCount = 1;
            maxCount=1;
            flag = 0;
        }
        else
        {
            if(min > num)
            {
                min = num;
                minCount = 1;
            }
            else if(min == num)
            {
                minCount++;
            }
            else if(max < num)
            {
                max = num;
                maxCount = 1;
            }
            else if(max == num)
            {
                maxCount++;
            }
        }
   }

    if(max != min)
    {
        printf("%d %d\n",(max-min),(minCount*maxCount));
    }
    else
    {
        printf("0 1\n");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
int arr[200005];
int compare(int *a,int *b){
    return *a-*b;
}
int bound(int arr[],int size,int target,int check){
    int f,m,l;
    f=0;
    l=size;
    if(!check){
    while(f<l){
            m=(f+l)/2;
        if(arr[m]<=target){
        f=m+1;
        }
        else l=m;
    }
    return l;}
    while(f<l){
            m=(f+l)/2;
        if(arr[m]>=target){
        l=m;
        }
        else f=m+1;
    }
    return size-l;
}
int main(){
    int a,b,c;
    scanf("%d",&a);
    int i;
    int min=INT_MAX;
    int max=0;
    for(i=0;i<a;i++){
            scanf("%d",arr+i);
            if(arr[i]>max)
                max=arr[i];
            if(arr[i]<min)
                min=arr[i];
    }
    qsort(arr,a,sizeof(int),compare);
    if(abs(max-min)==0){
     printf("%d %d",abs(max-min),a-1);
     return 0;
    }
    printf("%d %d",abs(max-min),bound(arr,a,max,1)*bound(arr,a,min,0));

}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
int arr[200005];
int compare(int *a,int *b){
    return *a-*b;
}
int main(){
    int a,b,c;
    scanf("%d",&a);
    int i;
    int min=INT_MAX;
    int max=0;
    for(i=0;i<a;i++){
            scanf("%d",arr+i);
            if(arr[i]>max)
                max=arr[i];
            if(arr[i]<min)
                min=arr[i];
    }
    qsort(arr,a,sizeof(int),compare);
    if(abs(max-min)==0){
     printf("%d %lld",abs(max-min),(long long int)((1+(a-1))*((a-1)/2.0)));
     return 0;
    }
    i=0;
    while(arr[i]==min)
        i++;
    int cnt1=i;
    i=a-1;
    int cnt2=0;
    while(arr[i]==max){
        cnt2++;
        i--;}
    printf("%d %d",abs(max-min),(long long int)cnt1*cnt2);
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
int arr[200005];
int compare(int *a,int *b){
    return *a-*b;
}
int main(){
    int a,b,c;
    scanf("%d",&a);
    int i;
    int min=INT_MAX;
    int max=0;
    for(i=0;i<a;i++){
            scanf("%d",arr+i);
            if(arr[i]>max)
                max=arr[i];
            if(arr[i]<min)
                min=arr[i];
    }
    qsort(arr,a,sizeof(int),compare);
    if(abs(max-min)==0){
     printf("%d %lld",abs(max-min),(long long int)((1+(a-1))*((a-1)/2.0)));
     return 0;
    }
    i=0;
    while(arr[i]==min)
        i++;
    int cnt1=i;
    i=a-1;
    int cnt2=0;
    while(arr[i]==max){
        cnt2++;
        i--;}
    printf("%d %lld",abs(max-min),(long long int)cnt1*cnt2);
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
int arr[200005];
int compare(int *a,int *b){
    return *a-*b;
}
long long int bound(int arr[],int size,int target,int check){
    int f,m,l;
    f=0;
    l=size;
    if(!check){
    while(f<l){
            m=(f+l)/2;
        if(arr[m]<=target){
        f=m+1;
        }
        else l=m;
    }
    return l;}
    while(f<l){
            m=(f+l)/2;
        if(arr[m]>=target){
        l=m;
        }
        else f=m+1;
    }
    return size-l;
}
int main(){
    int a,b,c;
    scanf("%d",&a);
    int i;
    int min=INT_MAX;
    int max=0;
    for(i=0;i<a;i++){
            scanf("%d",arr+i);
            if(arr[i]>max)
                max=arr[i];
            if(arr[i]<min)
                min=arr[i];
    }
    qsort(arr,a,sizeof(int),compare);
    if(abs(max-min)==0){
     printf("%d %d",abs(max-min),(int)((1+(a-1))*((a-1)/2.0)));
     return 0;
    }
    printf("%d %lld",abs(max-min),bound(arr,a,max,1)*(long long int)bound(arr,a,min,0));

}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
int arr[200005];
int compare(int *a,int *b){
    return *a-*b;
}
long long int bound(int arr[],int size,int target,int check){
    int f,m,l;
    f=0;
    l=size;
    if(!check){
    while(f<l){
            m=(f+l)/2;
        if(arr[m]<=target){
        f=m+1;
        }
        else l=m;
    }
    return l;}
    while(f<l){
            m=(f+l)/2;
        if(arr[m]>=target){
        l=m;
        }
        else f=m+1;
    }
    return size-l;
}
int main(){
    int a,b,c;
    scanf("%d",&a);
    int i;
    int min=INT_MAX;
    int max=0;
    for(i=0;i<a;i++){
            scanf("%d",arr+i);
            if(arr[i]>max)
                max=arr[i];
            if(arr[i]<min)
                min=arr[i];
    }
    qsort(arr,a,sizeof(int),compare);
    if(abs(max-min)==0){
     printf("%d %lld",abs(max-min),(long long int)(((long long int)1+((long long int)a-1))*(((long long int)a-1)/2.0)));
     return 0;
    }
    printf("%d %lld",abs(max-min),bound(arr,a,max,1)*(long long int)bound(arr,a,min,0));

}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
int arr[200005];
int compare(int *a,int *b){
    return *a-*b;
}
long long int bound(int arr[],int size,int target,int check){
    int f,m,l;
    f=0;
    l=size;
    if(!check){
    while(f<l){
            m=(f+l)/2;
        if(arr[m]<=target){
        f=m+1;
        }
        else l=m;
    }
    return l;}
    while(f<l){
            m=(f+l)/2;
        if(arr[m]>=target){
        l=m;
        }
        else f=m+1;
    }
    return size-l;
}
int main(){
    int a,b,c;
    scanf("%d",&a);
    int i;
    int min=INT_MAX;
    int max=0;
    for(i=0;i<a;i++){
            scanf("%d",arr+i);
            if(arr[i]>max)
                max=arr[i];
            if(arr[i]<min)
                min=arr[i];
    }
    qsort(arr,a,sizeof(int),compare);
    if(abs(max-min)==0){
     printf("%d %d",abs(max-min),(int)((1+a)*(a/2.0)));
     return 0;
    }
    printf("%d %lld",abs(max-min),bound(arr,a,max,1)*(long long int)bound(arr,a,min,0));

}


#include<stdio.h>
int main()
{
    long long int n,i,j,max=0,count=0,l,m,min=200001,count2=0;
    scanf("%I64d",&n);
    long long int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
   /* for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if((a[i]-a[j])>max)
            max=a[i]-a[j];
        }
    }*/
    if(max==min)
        printf("%I64d %I64d",max-min,1);
    else
    {
        for(l=0;l<n;l++)
        {
            if(a[l]==max)
            count++;
            if(a[l]==min)
                count2++;
        }
        printf("%I64d %I64d",max-min,count*count2);
    }

}


#include<stdio.h>
int main()
{
    long long int n,i,j,max=0,count=0,l,m,min=200001,count2=0;
    scanf("%I64d",&n);
    long long int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
   /* for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if((a[i]-a[j])>max)
            max=a[i]-a[j];
        }
    }*/
        for(l=0;l<n;l++)
        {
            if(a[l]==max)
            count++;
            if(a[l]==min)
                count2++;
        }
        if(max==min)
            printf("%I64d %I64d",max-min,(n*(n-1))/2)
        printf("%I64d %I64d",max-min,count*count2);

}


#include<stdio.h>
int main()
{
    long long int n,i,j,max=0,count=0,l,m,min=200001,count2=0;
    scanf("%I64d",&n);
    long long int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
   /* for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if((a[i]-a[j])>max)
            max=a[i]-a[j];
        }
    }*/
        for(l=0;l<n;l++)
        {
            if(a[l]==max)
            count++;
            if(a[l]==min)
                count2++;
        }
        if(max==min)
            printf("%I64d %I64d",max-min,(n*(n-1))/2);
        else
        printf("%I64d %I64d",max-min,count*count2);

}


#include<stdio.h>
int main()
{
    long long int n,i,j,max=0,count=0,l,m,min=200001;
    scanf("%I64d",&n);
    long long int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
   /* for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if((a[i]-a[j])>max)
            max=a[i]-a[j];
        }
    }*/
    for(l=0;l<n;l++)
    {
        for(m=0;m<n;m++)
        {
            if((a[l]-a[m])==max-min)
            count++;
        }
    }
    printf("%I64d %I64d",max-min,count);
}


#include<stdio.h>
int main()
{
    long long int n,i,j,max=0,count=0,l,m,min=20000000000,count2=0;
    scanf("%I64d",&n);
    long long int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
   /* for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if((a[i]-a[j])>max)
            max=a[i]-a[j];
        }
    }*/
        for(l=0;l<n;l++)
        {
            if(a[l]==max)
            count++;
            if(a[l]==min)
                count2++;
        }
        if(max==min)
            printf("%I64d %I64d",max-min,(n*(n-1))/2);
        else
        printf("%I64d %I64d",max-min,count*count2);

}


#include<stdio.h>
int main()
{
    long long int n,i,j,max=0,count=0,l,m;
    scanf("%I64d",&n);
    long long int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if((a[i]-a[j])>max)
            max=a[i]-a[j];
        }
    }
    for(l=0;l<n;l++)
    {
        for(m=0;m<n;m++)
        {
            if((a[l]-a[m])==max)
            count++;
        }
    }
    printf("%I64d %I64d",max,count);
}


#include<stdio.h>
int main()
{
    long long int n,i,j,max=0,count=0,l,m,min=200001,count2=0;
    scanf("%I64d",&n);
    long long int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
   /* for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if((a[i]-a[j])>max)
            max=a[i]-a[j];
        }
    }*/
    for(l=0;l<n;l++)
    {
            if(a[l]==max)
            count++;
            if(a[l]==min)
                count2++;
    }
    printf("%I64d %I64d",max-min,count*count2);
}


#include<stdio.h>
//#include<string.h>
#include<math.h>

main()
{
    //freopen("out.txt", "r", stdin);

    int n, m, c = 1, i, max = 0, min = 999999999;
    long long cmax = 0, cmin = 0;

    scanf("%d", &n);
    int a[n];
    for(i = 0; i<n; i++)
    {
        scanf("%d", &a[i]);
        if(a[i]>=max)
            max = a[i];
        if(a[i]<=min)
            min = a[i];

    }

    if(max == min)
    {
        printf("0 %I64d", n*(n-1)/2 );
        return 0;
    }

    for(i = 0; i<n; i++)
    {
        if(a[i]==max)
            cmax++;
        if(a[i]==min)
            cmin++;
    }

    printf("%d %I64d", max-min, cmax*cmin);

}


#include<stdio.h>
//#include<string.h>
#include<math.h>

main()
{
    //freopen("out.txt", "r", stdin);

    int m, c = 1, i, max = 0, min = 99999999999;
    long long cmax = 0, cmin = 0, n;

    scanf("%I64d", &n);
    int a[n];
    for(i = 0; i<n; i++)
    {
        scanf("%d", &a[i]);
        if(a[i]>=max)
            max = a[i];
        if(a[i]<=min)
            min = a[i];

    }

    if(max == min)
    {
        printf("0 %I64d", n*(n-1)/2 );
        return 0;
    }

    for(i = 0; i<n; i++)
    {
        if(a[i]==max)
            cmax++;
        if(a[i]==min)
            cmin++;
    }

    printf("%d %I64d", max-min, cmax*cmin);

    //printf("0 %I64d", n*(n-1)/2 );

}


#include<stdio.h>
//#include<string.h>
#include<math.h>

main()
{
    //freopen("out.txt", "r", stdin);

    int m, c = 1, i, max = 0, min = 999999999;
    long long cmax = 0, cmin = 0, n;

    scanf("%I64d", &n);
    int a[n];
    for(i = 0; i<n; i++)
    {
        scanf("%d", &a[i]);
        if(a[i]>=max)
            max = a[i];
        if(a[i]<=min)
            min = a[i];

    }

    if(max == min)
    {
        printf("0 %I64d", n*(n-1)/2 );
        return 0;
    }

    for(i = 0; i<n; i++)
    {
        if(a[i]==max)
            cmax++;
        if(a[i]==min)
            cmin++;
    }

    printf("%d %I64d", max-min, cmax*cmin);

    //printf("0 %I64d", n*(n-1)/2 );

}


#include<stdio.h>
//#include<string.h>
#include<math.h>

main()
{
    //freopen("out.txt", "r", stdin);

    int m, c = 1, i, max = 0, min = 999999999;
    long long cmax = 0, cmin = 0, n;

    scanf("%I64d", &n);
    int a[n];
    for(i = 0; i<n; i++)
    {
        scanf("%d", &a[i]);
        if(a[i]>=max)
            max = a[i];
        if(a[i]<=min)
            min = a[i];

    }

    if(max == min)
    {
        printf("0 %I64d", n*(n-1)/2 );
        return 0;
    }

    for(i = 0; i<n; i++)
    {
        if(a[i]==max)
            cmax++;
        if(a[i]==min)
            cmin++;
    }

    printf("%d %I64d", max-min, cmax*cmin);

}