// #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432
// 我用的是向量模拟的
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main() {
ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
int n, q, x, top, tail;
cin >> n >> q;
vector<int> a(n, 0);
top = 0;// The first expect start.//------------除非队列为空不然都指向第一个
tail = 0;// The next of end.
string s;
bool is_full = 0;//--------用于当top==tail时辅助判断队列是空还是满
while(q--){
cin >> s;
if (s == "push"){
cin >> x;
if (tail == top && is_full){
cout << "full\n";
}
else{
a[tail] = x;
tail++;
if (tail == n) tail = 0;//----------循环处理
if (top == tail) is_full = 1;
}
}
else if (s == "front"){
if (top == tail && !is_full)
cout << "empty\n";
else
cout << a[top] << '\n';
}
else{
if (top == tail && !is_full)
cout << "empty\n";
else{
cout << a[top] << '\n';
if (top == n - 1) top = 0;//----------循环处理
else top++;
if (top == tail) is_full = 0;
}
}
}
return 0;
}
// 64 位输出请用 printf("%lld")