#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 abs(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int t, n, i;
  scanf("%d", &t);
  for (i = 0; i < t; i++) {
    scanf("%d", &n);
    n = (((((n * 567) / 9) + 7492) * 235) / 47) - 498;
    n = n / 10;
    n = abs(n % 10);
    printf("%d\n", n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11dc <main+0xac>
lea    0xe97(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
imul   $0x237,-0xc(%rbp),%eax
mov    $0x9,%ecx
cltd
idiv   %ecx
add    $0x1d44,%eax
imul   $0xeb,%eax,%eax
mov    $0x2f,%ecx
cltd
idiv   %ecx
sub    $0x1f2,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <abs@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1156 <main+0x26>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11f0 <main+0xd0>
xor    %ebp,%ebp
lea    0xeb4(%rip),%r14
mov    %rsp,%r15
lea    0xead(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
imul   $0x39d5,(%rsp),%eax
mov    %eax,%ecx
add    $0x1add6c,%ecx
movslq %ecx,%rcx
imul   $0xffffffffae4c415d,%rcx,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
add    $0x1add6c,%eax
mov    %eax,%ecx
sar    $0x5,%ecx
shr    $0x1f,%eax
add    %ecx,%eax
add    $0xfffffe0e,%eax
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,%esi
neg    %esi
cmovs  %eax,%esi
mov    %esi,(%rsp)
mov    %rbx,%rdi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     1160 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\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* %4
br label %6
6: ; preds = %26, %0
%7 = load i32, i32* %4
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %29
10: ; preds = %6
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
%13 = mul nsw i32 %12, 567
%14 = sdiv i32 %13, 9
%15 = add nsw i32 %14, 7492
%16 = mul nsw i32 %15, 235
%17 = sdiv i32 %16, 47
%18 = sub nsw i32 %17, 498
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = sdiv i32 %19, 10
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = srem i32 %21, 10
%23 = call i32 @abs(i32 %22)
store i32 %23, i32* %3
%24 = load i32, i32* %3
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %10
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %6
29: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\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 %23
8: ; preds = %0, %8
%9 = phi i32 [ %20, %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 = mul i32 %11, 14805
%13 = add i32 %12, 1760620
%14 = sdiv i32 %13, 47
%15 = add nsw i32 %14, -498
%16 = sdiv i32 %15, 10
%17 = srem i32 %16, 10
%18 = call i32 @llvm.abs.i32(i32 %17, i1 true)
store i32 %18, i32* %2
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = add nuw nsw i32 %9, 1
%21 = load i32, i32* %1
%22 = icmp slt i32 %20, %21
br i1 %22, label %8, label %23
23: ; preds = %8, %0
ret i32 0
}