#include <bits/stdc++.h>
 
using namespace std;
 
const int MAX_SIZE = 6;
 
int main() {
    vector<int> input = {1, 2, 3, -1, -1, 4, 5, 6, 7, 8, 0};
    // vector<int> input = {1, -1, -1, 2, 3, -1, -1, 4, 5, 6, 7, 8, 9, 0};
 
    int data[MAX_SIZE] = {0};
 
    int head = 0;
    int len = 0;
 
    for (int i = 0; i < input.size(); i++) {
        // dbg
        // cout << "head: " << head << ", len: " << len << ' ';
        // for (int j = 0; j < MAX_SIZE; j++) {
        //     cout << data[j] << " ";
        // }
        // cout << endl;
 
        int now = input[i];
 
        // end of input
        if (now == 0) {
            break;
        }
 
        // pop from queue
        if (now == -1) {
            if (len == 0) {
                cerr << "Error: queue is empty when pop" << endl;
                return 1;
            }
            head = (head + 1) % MAX_SIZE;
            len--;
            continue;
        }
 
        // push to queue
        if (len == MAX_SIZE) {
            cerr << "Error: queue is full when push" << endl;
            return 1;
        }
 
        data[(head + len) % MAX_SIZE] = now;
        len++;
    }
}
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAXN = 1e5 + 5;
 
int main() {
    int stack[MAXN];
    int top = 0;
 
    string s = "(([{}][{}]))";
 
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '(' || s[i] == '[' || s[i] == '{') {
            stack[top++] = s[i];
            continue;
        }
        if (top == 0) {
            cout << "NO" << endl;
            return 0;
        }
        if (s[i] == ')' && stack[top - 1] == '(') {
            top--;
        } else if (s[i] == ']' && stack[top - 1] == '[') {
            top--;
        } else if (s[i] == '}' && stack[top - 1] == '{') {
            top--;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
}