import java.io.BufferedReader;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.StringTokenizer; public class Solution {static int N, M;static int[] A;static boolean[] D;public static void main(String[] args) throws IOException {//System.setIn(new FileInputStream("res/inputPre07.txt"));//System.setIn(new FileInp..