static void BFS() {
        HashMap<Integer, Boolean> hm = new HashMap<Integer, Boolean>();
        HashMap<Integer, Integer> ht = new HashMap<Integer, Integer>();
        Queue<Integer> q = new LinkedList<Integer>();
        hm.put(0, Boolean.TRUE);
        for (int i = 1; i < P; i++) {
            hm.put(i, Boolean.FALSE);
        }
        q.add(0);
        int l = 0;
        while (!q.isEmpty()) {
            l++;
            int y = q.size();
            for (int o = 0; o < y; o++) {
                int u = q.poll();
                for (int i = 0; i < P; i++) {
                    if (m[u][i] == 1 && hm.get(i) == false & i != u) {
                        m[u][i] = 0;
                        hm.put(i, Boolean.TRUE);
                        ht.put(i, l);
                        q.add(i);
                    }
                }
            }
        }
        for (int i = 1; i <= P - 1; i++) {
            if (ht.get(i) != 0) {
                System.out.println(ht.get(i));
            } else {
                System.out.println("INF");
            }
        }
    }