#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
queue<int> q;
string op;
while(n--) {
cin >> op;
if(op == "push") {
int x;
cin >> x;
q.push(x);
}
else if(op == "pop") {
if(q.empty()) {
cout << "error\n";
} else {
cout << q.front() << "\n";
q.pop();
}
}
else { // front
if(q.empty()) {
cout << "error\n";
} else {
cout << q.front() << "\n";
}
}
}
return 0;
}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
Queue<Integer> q = new LinkedList<>();
for(int i = 0; i < n; i++) {
String op = sc.next();
if(op.equals("push")) {
int x = sc.nextInt();
q.offer(x);
}
else if(op.equals("pop")) {
if(q.isEmpty()) {
System.out.println("error");
} else {
System.out.println(q.poll());
}
}
else { // front
if(q.isEmpty()) {
System.out.println("error");
} else {
System.out.println(q.peek());
}
}
}
}
}
from collections import deque
import sys
input = sys.stdin.readline
n = int(input())
q = deque()
for _ in range(n):
op = input().strip()
if op.startswith("push"):
_, x = op.split()
q.append(int(x))
elif op == "pop":
if not q:
print("error")
else:
print(q.popleft())
elif op == "front":
if not q:
print("error")
else:
print(q[0])