Under construction

Still being built. Things may change

Vertex covers

Time limit3sMemory limit512 MB

Summary
For each query with n vertices and k, count simple graphs whose minimum vertex cover has size exactly k, printed modulo 2.
Level

Hard8 of 10

Topics
Combinatorics, Math, Bit manipulation
Solved
No attempts yet

Problem

A vertex cover of an undirected simple graph G=(V,E)G = (V, E) is a subset S⊆VS \subseteq V such that for every (u,v)∈E(u, v) \in E we have u∈Su \in S or v∈Sv \in S. The size aa of a vertex cover SS is ∣S∣|S|.

Find the number of simple graphs with nn vertices whose smallest vertex cover has size exactly kk.

Two graphs G_1=(V,E_1)G\_1 = (V, E\_1) and G_2=(V,E_2)G\_2 = (V, E\_2) are different if and only if there exist two vertices u,v∈Vu, v \in V (u≠vu\neq v) such that the edge (u,v)(u, v) belongs to exactly one of the sets E_1E\_1 and E_2E\_2.

Since the answer can be very large, it suffices to print it modulo 22.

Input

The first line contains an integer qq (1≤q≤281 \le q \le 2^{8}), the number of queries. Each of the following qq lines contains two integers nin_i and kik_i (1≤ni<281 \le n_i < 2^{8}, 0≤ki<ni0 \le k_i < n_i), where nin_i is the number of vertices of GG (∣V∣=ni|V|=n_i) and kik_i is the desired size of the smallest vertex cover.

Output

Print qq lines. The ii-th line contains the answer to the ii-th query, either 00 or 11.

Hints

In the first query VV has size 33. The simple graphs on VV whose smallest vertex cover has size 11 are exactly the graphs with one or two edges. There are six of them.

In the second query, a graph on 55 vertices whose smallest vertex cover has size 44 must be a clique.

Examples1

  1. Example 1

    Input
    4
    3 1
    5 4
    5 3
    57 32
    
    Expected output
    0
    1
    1
    1