import java.io.*;
import java.util.*;
public class DrBTreeII {
try {
while (!st.hasMoreTokens()) {
if (s == null)
return null;
}
return st.nextToken();
return null;
}
}
mem = new int [1005][1005];
for (int [] v
: mem
) Arrays.
fill(v,
-1);
int CASES
= Integer.
parseInt( next
() ); while (CASES-- > 0) {
int L
= Integer.
parseInt( next
() ); int K
= Integer.
parseInt( next
() );
int ans = solve(L, K);
out.println( ans );
}
//
out.flush();
}
static final long MOD = 1000000000 + 7, CHARS = 10;
static int [][] mem;
static int solve(int len, int mirrors) {
if (len == 0 && mirrors == 0) {
return 1;
}
if (len < 0 || mirrors < 0) {
return 0;
}
if (mem[len][mirrors] != -1) {
return mem[len][mirrors];
}
long ans = 0;
if (len % 2 == 1) {
// place middle
ans = CHARS * solve(len - 1, mirrors - 1);
ans %= MOD;
} else {
// place not mirror
ans = CHARS * (CHARS - 1) * solve(len - 2, mirrors);
ans %= MOD;
ans += CHARS * solve(len - 2, mirrors - 1);
ans %= MOD;
}
// out.printf("solve(%d, %d) = %d\n", len, mirrors, ans);
return mem[len][mirrors] = (int)ans;
}
}
CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwuKjsKCnB1YmxpYyBjbGFzcyBEckJUcmVlSUkgewoKCXN0YXRpYyBCdWZmZXJlZFJlYWRlciBiciA9IG5ldyBCdWZmZXJlZFJlYWRlcihuZXcgSW5wdXRTdHJlYW1SZWFkZXIoU3lzdGVtLmluKSk7CglzdGF0aWMgUHJpbnRXcml0ZXIgb3V0ID0gbmV3IFByaW50V3JpdGVyKG5ldyBCdWZmZXJlZE91dHB1dFN0cmVhbShTeXN0ZW0ub3V0KSk7CglzdGF0aWMgU3RyaW5nVG9rZW5pemVyIHN0ID0gbmV3IFN0cmluZ1Rva2VuaXplcigiIik7CgoJcHVibGljIHN0YXRpYyBTdHJpbmcgbmV4dCgpIHsKCQl0cnkJewoJCXdoaWxlICghc3QuaGFzTW9yZVRva2VucygpKSB7CgkJCVN0cmluZyBzID0gYn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