{"problem":{"name":"Near Assignment","description":{"content":"You are given integer sequences of length $N$: $A=(A_1,A_2,\\cdots,A_N)$ and $B=(B_1,B_2,\\cdots,B_N)$, and an integer $K$. You can perform the following operation zero or more times. *   Choose intege","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc183_b"},"statements":[{"statement_type":"Markdown","content":"You are given integer sequences of length $N$: $A=(A_1,A_2,\\cdots,A_N)$ and $B=(B_1,B_2,\\cdots,B_N)$, and an integer $K$.\nYou can perform the following operation zero or more times.\n\n*   Choose integers $i$ and $j$ ($1 \\leq i,j \\leq N$). Here, $|i-j| \\leq K$ must hold. Then, change the value of $A_i$ to $A_j$.\n\nDetermine whether it is possible to make $A$ identical to $B$.\nThere are $T$ test cases for each input.\n\n## Constraints\n\n*   $1 \\leq T \\leq 125000$\n*   $1 \\leq K < N \\leq 250000$\n*   $1 \\leq A_i,B_i \\leq N$\n*   The sum of $N$ across all test cases in each input is at most $250000$.\n*   All input values are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$T$\n$case_1$\n$case_2$\n$\\vdots$\n$case_T$\n\nEach test case is given in the following format:\n\n$N$ $K$\n$A_1$ $A_2$ $\\cdots$ $A_N$\n$B_1$ $B_2$ $\\cdots$ $B_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc183_b","tags":[],"sample_group":[["4\n3 1\n1 1 2\n1 2 2\n5 4\n2 4 5 1 3\n2 1 3 2 2\n13 1\n3 1 3 3 5 3 3 4 2 2 2 5 1\n5 3 3 3 4 2 2 2 2 5 5 1 3\n20 14\n10 6 6 19 13 16 15 15 2 10 2 16 9 12 2 6 13 5 5 9\n5 9 6 2 10 19 16 15 13 12 10 2 9 6 5 16 19 12 15 13","Yes\nYes\nNo\nYes\n\nConsider the first test case. If we operate with $i=2$ and $j=3$, the value of $A_2$ will be changed to $A_3=2$, resulting in $A=(1,2,2)$."]],"created_at":"2026-03-03 11:01:14"}}