// File: /workspace/github_cpp_makefile_star2_O2/kdungs[P]codecon/src/rooms.cc
// Function: main
int main() {
  auto line = std::string{};
  getline(std::cin, line);

  auto nrooms = 0ul;
  try {
    nrooms = std::stoul(line);
  } catch (const std::exception&) {
    return EXIT_FAILURE;
  }
  if (nrooms < 1) {
    return EXIT_FAILURE;
  }

  auto rooms = std::vector<Room>(nrooms);
  while (getline(std::cin, line)) {
    auto input = splitAtDash(line);
    if (input.size() == 2) {  // it's a query
      auto slot = input[0] - 1;  // correct indexing
      auto nslots = input[1];
      auto arooms = query(rooms, slot, nslots);

      if (arooms.empty()) {
        std::cout << "None\n";
      } else {
        std::transform(std::begin(arooms), std::end(arooms), std::begin(arooms),
                       [](unsigned x) { return x + 1; });  // correct indexing
        printWithSpace(arooms);
        std::cout << '\n';
      }
    } else if (input.size() == 3) {  // it's a booking
      if (input[0] == 0 || input[0] > nrooms) {
        std::cerr << "Invalid room ID!\n";
        return EXIT_FAILURE;
      }
      auto room = input[0] - 1;
      auto slot = input[1] - 1;
      auto nslots = input[2];
      if (rooms[room].book(slot, nslots)) {
        std::cout << "Y\n";
      } else {
        std::cout << "N\n";
      }
    } else {  // it's BS
      std::cerr << "Invalid input!\n";
      return EXIT_FAILURE;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x2b65(%rip), %rdi      # 0x4fd8
leaq 0x48(%rsp), %rsi
callq 0x2040
leaq 0x48(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x26f0
movq %rax, %rbx
testq %rax, %rax
je 0x2614
leaq 0x30(%rsp), %rdi
leaq 0x18(%rsp), %rdx
movq %rbx, %rsi
callq 0x270c
xorl %ebp, %ebp
movq 0x2b25(%rip), %r14      # 0x4fd8
leaq 0x48(%rsp), %r15
leaq 0x18(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x2040
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x25f1
movq %r12, %rdi
movq %r15, %rsi
callq 0x236a
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq $0x3, %rcx
je 0x2578
leaq 0xb1f(%rip), %rsi       # 0x3022
cmpq $0x2, %rcx
jne 0x2591
movl (%rax), %edx
movl 0x4(%rax), %ecx
decl %edx
movq %rsp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x22dc
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
cmpq %rcx, %rax
jne 0x254f
movq 0x2a92(%rip), %rdi      # 0x4fc8
leaq 0xac7(%rip), %rsi       # 0x3004
callq 0x2100
jmp 0x256b
movl (%rax), %edx
incl %edx
movq %rdx, (%rax)
addq $0x8, %rax
cmpq %rcx, %rax
jne 0x2544
movq %rsp, %rdi
callq 0x275d
movq 0x2a65(%rip), %rdi      # 0x4fc8
pushq $0xa
popq %rsi
callq 0x2130
movq %rsp, %rdi
callq 0x2a54
movb $0x1, %r13b
jmp 0x25e0
movl (%rax), %edi
testq %rdi, %rdi
sete %cl
cmpq %rdi, %rbx
setb %dl
orb %cl, %dl
leaq 0xa7b(%rip), %rsi       # 0x300a
je 0x25a5
movq 0x2a58(%rip), %rdi      # 0x4ff0
callq 0x2100
xorl %r13d, %r13d
pushq $0x1
popq %rbp
jmp 0x25e0
decl %edi
movl 0x4(%rax), %esi
movl 0x8(%rax), %edx
decl %esi
shlq $0x5, %rdi
addq 0x30(%rsp), %rdi
callq 0x27d4
testb %al, %al
leaq 0xa59(%rip), %rsi       # 0x301f
leaq 0xa4f(%rip), %rax       # 0x301c
cmovneq %rax, %rsi
movb $0x1, %r13b
movq 0x29ed(%rip), %rdi      # 0x4fc8
callq 0x2100
movq %r12, %rdi
callq 0x2bcc
testb %r13b, %r13b
jne 0x24bd
leaq 0x30(%rsp), %rdi
callq 0x2da2
jmp 0x2617
jmp 0x2634
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x2668
movq %rbx, %rdi
callq 0x2070
callq 0x2180
pushq $0x1
popq %rbp
leaq 0x48(%rsp), %rdi
callq 0x2080
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2634
movq %rax, %rbx
jmp 0x2668
jmp 0x263d
jmp 0x263d
movq %rax, %rbx
jmp 0x264d
movq %rax, %rbx
movq %rsp, %rdi
callq 0x2a54
leaq 0x18(%rsp), %rdi
callq 0x2bcc
jmp 0x265e
jmp 0x265b
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x2da2
leaq 0x48(%rsp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x2190