Language: C++

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Queue;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.LinkedList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APondSkater solver = new APondSkater();
        solver.solve(1, in, out);
        out.close();
    }

    static class APondSkater {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int k = sc.nextInt();
            char[][] grid = new char[n][m];
            Integer[][] dist = new Integer[n][m];
            int[] dx = {-1, 0, 1, 0};
            int[] dy = {0, -1, 0, 1};
            int x1 = sc.nextInt() - 1;
            int y1 = sc.nextInt() - 1;
            int x2 = sc.nextInt() - 1;
            int y2 = sc.nextInt() - 1;
            for (int i = 0; i < n; i++) {
                grid[i] = sc.nextLine().toCharArray();

            }
            Queue<pair> q = new LinkedList<>();
            q.add(new pair(x1, y1));
            dist[x1][y1] = 0;
            while (q.size() > 0) {
                pair cur = q.poll();
                if (cur.a == x2 && cur.b == y2) break;
                for (int i = 0; i < 4; i++) {
                    for (int c = 1; c <= k; c++) {
                        if (valid(cur.a + c * dx[i], cur.b + c * dy[i], n, m) && grid[cur.a + c * dx[i]][cur.b + c * dy[i]] == '.') {
                            if (dist[cur.a + c * dx[i]][cur.b + c * dy[i]] == null) {
                                dist[cur.a + c * dx[i]][cur.b + c * dy[i]] = 1 + dist[cur.a][cur.b];
                                q.add(new pair(cur.a + c * dx[i], cur.b + c * dy[i]));
                            }

                        } else break;
                    }
                }
            }
            pw.println(dist[x2][y2] == null ? -1 : dist[x2][y2]);

        }

        boolean valid(int i, int j, int n, int m) {
            if (i < 0) return false;
            if (i >= n) return false;
            if (j < 0) return false;
            if (j >= m) return false;
            return true;
        }

        public class pair {
            int a;
            int b;

            public pair(int a, int b) {
                this.a = a;
                this.b = b;
            }

        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

    }
}



Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.OutputStream;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.IOException;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.io.InputStream;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.io.PrintWriter;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.util.Collection;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
    6 | import java.io.IOException;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
    7 | import java.io.InputStreamReader;
      | ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: 'import' does not name a type
    8 | import java.util.StringTokenizer;
      | ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: 'import' does not name a type
    9 | import java.util.Queue;
      | ^~~~~~
a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:1: error: 'import' does not name a type
   10 | import java.io.BufferedReader;
      | ^~~~~~
a.cc:10:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:11:1: error: 'import' does not name a type
   11 | import java.io.FileReader;
      | ^~~~~~
a.cc:11:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:12:1: error: 'import' does not name a type
   12 | import java.util.LinkedList;
      | ^~~~~~
a.cc:12:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:13:1: error: 'import' does not name a type
   13 | import java.io.InputStream;
      | ^~~~~~
a.cc:13:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:19:1: error: expected unqualified-id before 'public'
   19 | public class Main {
      | ^~~~~~