#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, i, num;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d", &num);
    if (!(num % 4) || !(num % 400)) {
      printf("S\n");
    } else {
      printf("N\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ba <main+0x9a>
lea    0xea7(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     118a <main+0x6a>
mov    -0x10(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    119b <main+0x7b>
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
jmp    11a7 <main+0x87>
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
jmp    11ac <main+0x8c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1146 <main+0x26>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecd(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11b2 <main+0x92>
xor    %ebp,%ebp
lea    0xeb3(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xeaa(%rip),%rbx
lea    0xea5(%rip),%r12
jmp    1184 <main+0x64>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   $0x3,%al
cmove  %rbx,%rdi
call   1030 <puts@plt>
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jge    11b2 <main+0x92>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
imul   $0xc28f5c29,%eax,%ecx
add    $0x51eb850,%ecx
ror    $0x4,%ecx
mov    %rbx,%rdi
cmp    $0xa3d70b,%ecx
jb     1170 <main+0x50>
mov    %r12,%rdi
jmp    1170 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"S\0A\00"
@.str.2 = [3 x i8] c"N\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %27
10: ; preds = %6
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%12 = load i32, i32* %4
%13 = srem i32 %12, 4
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* %4
%17 = srem i32 %16, 400
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %15, %10
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %23
21: ; preds = %15
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
br label %24
24: ; preds = %23
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %6
27: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [2 x i8] c"S\00"
@str.3 = [2 x i8] c"N\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %0, %8
%9 = phi i32 [ %19, %8 ], [ 0, %0 ]
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = and i32 %11, 3
%13 = icmp eq i32 %12, 0
%14 = srem i32 %11, 400
%15 = icmp eq i32 %14, 0
%16 = or i1 %13, %15
%17 = select i1 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str.3, i64 0, i64 0)
%18 = call i32 @puts(i8* dereferenceable(1) %17)
%19 = add nuw nsw i32 %9, 1
%20 = load i32, i32* %1
%21 = icmp slt i32 %19, %20
br i1 %21, label %8, label %22
22: ; preds = %8, %0
ret i32 0
}