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