// File: 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
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movl $0x0, -0x4(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x2170
movq -0xe8(%rbp), %rsi
movq 0x79f8(%rip), %rdi      # 0x9fd8
callq 0x2040
jmp 0x25e7
movq $0x0, -0x40(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x28(%rbp), %rdi
movl $0xa, %edx
callq 0x2da0
movq %rax, -0xf0(%rbp)
jmp 0x260a
movq -0xf0(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x266b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2a88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2a88
movq -0x30(%rbp), %rdi
callq 0x2080
movq %rax, -0x48(%rbp)
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4c(%rbp)
callq 0x21c0
jmp 0x2666
jmp 0x2a6a
cmpq $0x1, -0x40(%rbp)
jae 0x2685
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4c(%rbp)
jmp 0x2a6a
movq -0x40(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x2e40
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x2e60
jmp 0x26b9
leaq -0x69(%rbp), %rdi
callq 0x2ed0
movq 0x790f(%rip), %rdi      # 0x9fd8
leaq -0x28(%rbp), %rsi
callq 0x2040
movq %rax, -0x108(%rbp)
jmp 0x26db
movq -0x108(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2160
movb %al, -0x109(%rbp)
jmp 0x26f9
movb -0x109(%rbp), %al
testb $0x1, %al
jne 0x2708
jmp 0x2a5a
leaq -0x88(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x2410
jmp 0x271a
leaq -0x88(%rbp), %rdi
callq 0x2ef0
cmpq $0x2, %rax
jne 0x28db
xorl %eax, %eax
movl %eax, %esi
leaq -0x88(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x2f10
movq -0x118(%rbp), %rdi
movl (%rax), %eax
decl %eax
movl %eax, -0x8c(%rbp)
movl $0x1, %esi
callq 0x2f10
movl (%rax), %eax
movl %eax, -0x90(%rbp)
movl -0x8c(%rbp), %edx
movl -0x90(%rbp), %ecx
leaq -0xa8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x2330
jmp 0x2788
leaq -0xa8(%rbp), %rdi
callq 0x2f30
testb $0x1, %al
jne 0x279a
jmp 0x280d
movq 0x7827(%rip), %rdi      # 0x9fc8
leaq 0x387c(%rip), %rsi      # 0x6024
callq 0x2120
jmp 0x27af
jmp 0x28ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x2ed0
jmp 0x2a88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2a7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2a4c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x2cd0
jmp 0x2a4c
leaq -0xa8(%rbp), %rdi
callq 0x2f70
movq %rax, -0x120(%rbp)
jmp 0x2822
movq -0x120(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x2fa0
movq %rax, -0x128(%rbp)
jmp 0x2845
movq -0x128(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x2f70
movq %rax, -0x130(%rbp)
jmp 0x2868
movq -0x130(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xb0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
callq 0x2aa0
movq %rax, -0x138(%rbp)
jmp 0x2899
movq -0x138(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x2fd0
jmp 0x28b5
movq 0x770c(%rip), %rdi      # 0x9fc8
movl $0xa, %esi
callq 0x2150
jmp 0x28c8
jmp 0x28ca
leaq -0xa8(%rbp), %rdi
callq 0x2cd0
jmp 0x2a2b
leaq -0x88(%rbp), %rdi
callq 0x2ef0
cmpq $0x3, %rax
jne 0x2a04
leaq -0x88(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f10
cmpl $0x0, (%rax)
je 0x291e
leaq -0x88(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f10
movl (%rax), %eax
cmpq -0x40(%rbp), %rax
jbe 0x2946
movq 0x76cb(%rip), %rdi      # 0x9ff0
leaq 0x36fe(%rip), %rsi      # 0x602a
callq 0x2120
jmp 0x2933
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4c(%rbp)
jmp 0x2a32
xorl %eax, %eax
movl %eax, %esi
leaq -0x88(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x2f10
movq -0x148(%rbp), %rdi
movl (%rax), %eax
decl %eax
movl %eax, -0xd4(%rbp)
movl $0x1, %esi
callq 0x2f10
movq -0x148(%rbp), %rdi
movl (%rax), %eax
decl %eax
movl %eax, -0xd8(%rbp)
movl $0x2, %esi
callq 0x2f10
movl (%rax), %eax
movl %eax, -0xdc(%rbp)
movl -0xd4(%rbp), %eax
movl %eax, %esi
leaq -0x68(%rbp), %rdi
callq 0x30a0
movq %rax, %rdi
movl -0xd8(%rbp), %esi
movl -0xdc(%rbp), %edx
callq 0x30c0
movb %al, -0x139(%rbp)
jmp 0x29c8
movb -0x139(%rbp), %al
testb $0x1, %al
jne 0x29d4
jmp 0x29eb
movq 0x75ed(%rip), %rdi      # 0x9fc8
leaq 0x365a(%rip), %rsi      # 0x603c
callq 0x2120
jmp 0x29e9
jmp 0x2a02
movq 0x75d6(%rip), %rdi      # 0x9fc8
leaq 0x3646(%rip), %rsi      # 0x603f
callq 0x2120
jmp 0x2a00
jmp 0x2a02
jmp 0x2a29
movq 0x75e5(%rip), %rdi      # 0x9ff0
leaq 0x3630(%rip), %rsi      # 0x6042
callq 0x2120
jmp 0x2a19
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4c(%rbp)
jmp 0x2a32
jmp 0x2a2b
movl $0x0, -0x4c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x2de0
movl -0x4c(%rbp), %eax
testl %eax, %eax
jne 0x2a61
jmp 0x2a47
jmp 0x26c2
leaq -0x88(%rbp), %rdi
callq 0x2de0
jmp 0x2a7f
movl $0x0, -0x4c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x3180
leaq -0x28(%rbp), %rdi
callq 0x20d0
movl -0x4(%rbp), %eax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0x3180
leaq -0x28(%rbp), %rdi
callq 0x20d0
movq -0x30(%rbp), %rdi
callq 0x21d0
nopw (%rax,%rax)