Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
896 B
2
Indexable
Never
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        for (int i = 0; i < T; i++) {
            int N = sc.nextInt();
            int M = sc.nextInt();
            int[] a = new int[N];
            int[] b = new int[M];
            if (N != M) {
                System.out.println(0);
            } else {
                for (int j = 0; j < M; j++) {
                    a[j] = sc.nextInt();
                }
                for (int j = 0; j < N; j++) {
                    b[j] = sc.nextInt();
                }
                if (Arrays.equals(a, b)) {
                    System.out.println(1);
                } else {
                    System.out.println(0);
                }
            }
        }
    }
}
Leave a Comment