// File: /workspace/github_cpp_makefile_star2_O1/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 $0x78, %rsp
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x2a19(%rip), %rdi      # 0x4fd8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %edx
movq 0x29fe(%rip), %rbx      # 0x4fd8
leaq 0x58(%rsp), %rsi
movq %rbx, %rdi
callq 0x21b0
movq 0x58(%rsp), %r12
callq 0x2030
movq %rax, %r15
movl (%rax), %ebp
movl $0x0, (%rax)
leaq 0x40(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x2050
cmpq %r12, (%r13)
je 0x2842
movq %rax, %r14
movl (%r15), %eax
testl %eax, %eax
je 0x2636
cmpl $0x22, %eax
jne 0x2639
leaq 0xa5f(%rip), %rdi       # 0x3090
callq 0x2150
movl %ebp, (%r15)
testq %r14, %r14
je 0x2810
leaq 0x40(%rsp), %rdi
leaq 0x28(%rsp), %rdx
movq %r14, %rsi
callq 0x2942
xorl %ebp, %ebp
leaq 0x58(%rsp), %r15
leaq 0x28(%rsp), %r12
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x27f7
movq %r12, %rdi
movq %r15, %rsi
callq 0x23df
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq $0x3, %rcx
je 0x272f
movl $0xf, %edx
leaq 0x960(%rip), %rsi       # 0x3022
cmpq $0x2, %rcx
jne 0x274d
movl (%rax), %edx
movl 0x4(%rax), %ecx
decl %edx
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x231c
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
cmpq %rcx, %rax
je 0x27a5
movl (%rax), %edx
incl %edx
movq %rdx, (%rax)
addq $0x8, %rax
cmpq %rcx, %rax
jne 0x26f5
leaq 0x10(%rsp), %rdi
callq 0x29e7
movb $0xa, 0xf(%rsp)
movl $0x1, %edx
movq 0x28a8(%rip), %rdi      # 0x4fc8
leaq 0xf(%rsp), %rsi
callq 0x2140
jmp 0x27bd
movl (%rax), %edi
testq %rdi, %rdi
sete %cl
cmpq %rdi, %r14
setb %dl
orb %cl, %dl
movl $0x11, %edx
leaq 0x8bf(%rip), %rsi       # 0x300a
je 0x2763
movq 0x289c(%rip), %rdi      # 0x4ff0
callq 0x2140
movl $0x1, %ebp
xorl %r13d, %r13d
jmp 0x27d7
decl %edi
movl 0x4(%rax), %esi
movl 0x8(%rax), %edx
decl %esi
shlq $0x5, %rdi
addq 0x40(%rsp), %rdi
callq 0x2a74
testb %al, %al
leaq 0x89b(%rip), %rsi       # 0x301f
leaq 0x891(%rip), %rax       # 0x301c
cmovneq %rax, %rsi
movb $0x1, %r13b
movl $0x2, %edx
movq 0x282a(%rip), %rdi      # 0x4fc8
callq 0x2140
jmp 0x27d7
movl $0x5, %edx
movq 0x2817(%rip), %rdi      # 0x4fc8
leaq 0x84c(%rip), %rsi       # 0x3004
callq 0x2140
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x27d4
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movb $0x1, %r13b
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x27ee
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
testb %r13b, %r13b
jne 0x2660
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2815
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
jmp 0x2815
movl $0x1, %ebp
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x2831
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2130
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x847(%rip), %rdi       # 0x3090
callq 0x20b0
jmp 0x2877
movq %rax, %rbx
cmpl $0x0, (%r15)
jne 0x285c
movl %ebp, (%r15)
cmpl $0x1, %edx
jne 0x28d4
movq %rbx, %rdi
callq 0x2080
movl $0x1, %ebp
callq 0x2190
jmp 0x2815
jmp 0x2877
movq %rax, %rbx
jmp 0x28d4
jmp 0x2880
jmp 0x2880
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x28bd
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
jmp 0x28bd
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2883
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
jmp 0x2883
jmp 0x28ba
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x28d4
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x28f0
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2130
movq %rbx, %rdi
callq 0x21a0