// File: /workspace/github_cpp_makefile_star2_O3/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 0x2a23(%rip), %rdi      # 0x4fd8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %edx
movq 0x2a08(%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 0x2838
movq %rax, %r14
movl (%r15), %eax
testl %eax, %eax
je 0x262c
cmpl $0x22, %eax
jne 0x262f
leaq 0xa69(%rip), %rdi       # 0x3090
callq 0x2150
movl %ebp, (%r15)
testq %r14, %r14
je 0x2806
leaq 0x40(%rsp), %rdi
leaq 0x28(%rsp), %rdx
movq %r14, %rsi
callq 0x2938
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 0x27ed
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 0x2725
movl $0xf, %edx
leaq 0x96a(%rip), %rsi       # 0x3022
cmpq $0x2, %rcx
jne 0x2743
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 0x279b
movl (%rax), %edx
incl %edx
movq %rdx, (%rax)
addq $0x8, %rax
cmpq %rcx, %rax
jne 0x26eb
leaq 0x10(%rsp), %rdi
callq 0x29eb
movb $0xa, 0xf(%rsp)
movl $0x1, %edx
movq 0x28b2(%rip), %rdi      # 0x4fc8
leaq 0xf(%rsp), %rsi
callq 0x2140
jmp 0x27b3
movl (%rax), %edi
testq %rdi, %rdi
sete %cl
cmpq %rdi, %r14
setb %dl
orb %cl, %dl
movl $0x11, %edx
leaq 0x8c9(%rip), %rsi       # 0x300a
je 0x2759
movq 0x28a6(%rip), %rdi      # 0x4ff0
callq 0x2140
movl $0x1, %ebp
xorl %r13d, %r13d
jmp 0x27cd
decl %edi
movl 0x4(%rax), %esi
movl 0x8(%rax), %edx
decl %esi
shlq $0x5, %rdi
addq 0x40(%rsp), %rdi
callq 0x2a78
testb %al, %al
leaq 0x8a5(%rip), %rsi       # 0x301f
leaq 0x89b(%rip), %rax       # 0x301c
cmovneq %rax, %rsi
movb $0x1, %r13b
movl $0x2, %edx
movq 0x2834(%rip), %rdi      # 0x4fc8
callq 0x2140
jmp 0x27cd
movl $0x5, %edx
movq 0x2821(%rip), %rdi      # 0x4fc8
leaq 0x856(%rip), %rsi       # 0x3004
callq 0x2140
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x27ca
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movb $0x1, %r13b
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x27e4
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
testb %r13b, %r13b
jne 0x2656
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x280b
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
jmp 0x280b
movl $0x1, %ebp
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x2827
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 0x851(%rip), %rdi       # 0x3090
callq 0x20b0
jmp 0x286d
movq %rax, %rbx
cmpl $0x0, (%r15)
jne 0x2852
movl %ebp, (%r15)
cmpl $0x1, %edx
jne 0x28ca
movq %rbx, %rdi
callq 0x2080
movl $0x1, %ebp
callq 0x2190
jmp 0x280b
jmp 0x286d
movq %rax, %rbx
jmp 0x28ca
jmp 0x2876
jmp 0x2876
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x28b3
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
jmp 0x28b3
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2879
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
jmp 0x2879
jmp 0x28b0
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x28ca
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x28e6
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2130
movq %rbx, %rdi
callq 0x21a0