{"problem":{"name":"I hate Matrix Construction","description":{"content":"Given are an integer $N$ and arrays $S$, $T$, $U$, and $V$, each of length $N$. Construct an $N×N$ matrix $a$ that satisfy the following conditions: *   $a_{i,j}$ is an integer. *   $0 \\leq a_{i,j} \\","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc164_f"},"statements":[{"statement_type":"Markdown","content":"Given are an integer $N$ and arrays $S$, $T$, $U$, and $V$, each of length $N$. Construct an $N×N$ matrix $a$ that satisfy the following conditions:\n\n*   $a_{i,j}$ is an integer.\n*   $0 \\leq a_{i,j} \\lt 2^{64}$.\n*   If $S_{i} = 0$, the bitwise AND of the elements in the $i$\\-th row is $U_{i}$.\n*   If $S_{i} = 1$, the bitwise OR of the elements in the $i$\\-th row is $U_{i}$.\n*   If $T_{i} = 0$, the bitwise AND of the elements in the $i$\\-th column is $V_{i}$.\n*   If $T_{i} = 1$, the bitwise OR of the elements in the $i$\\-th column is $V_{i}$.\n\nHowever, there may be cases where no matrix satisfies the conditions.\n\n## Constraints\n\n*   All values in input are integers.\n*   $1 \\leq N \\leq 500$\n*   $0 \\leq S_{i} \\leq 1$\n*   $0 \\leq T_{i} \\leq 1$\n*   $0 \\leq U_{i} \\lt 2^{64}$\n*   $0 \\leq V_{i} \\lt 2^{64}$\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$S_{1}$ $S_{2}$ $...$  $S_{N}$\n$T_{1}$ $T_{2}$ $...$  $T_{N}$\n$U_{1}$ $U_{2}$ $...$  $U_{N}$\n$V_{1}$ $V_{2}$ $...$  $V_{N}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc164_f","tags":[],"sample_group":[["2\n0 1\n1 0\n1 1\n1 0","1 1\n1 0\n\nIn Sample Input $1$, we need to find a matrix such that:\n\n*   the bitwise AND of the elements in the $1$\\-st row is $1$;\n*   the bitwise OR of the elements in the $2$\\-nd row is $1$;\n*   the bitwise OR of the elements in the $1$\\-st column is $1$;\n*   the bitwise AND of the elements in the $2$\\-nd column is $0$."],["2\n1 1\n1 0\n15 15\n15 11","15 11\n15 11"]],"created_at":"2026-03-03 11:01:13"}}