import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:16-

            int n = sc.nextInt();
            int d = sc.nextInt();
            int[][] vs = new int[n][d];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                }
            }

            int pairs = 0;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                }
            }

            out.println(pairs);
        }
    }

    private static boolean iseven(double val) {
        return val - (int) val == 0;
    }

    private static double dist(int[] a, int[] b) {
        double sum = 0.0;
        for (int i = 0; i < a.length; i++) {
            int t = a[i] - b[i];
            sum += t * t;
        }
        return Math.sqrt(sum);
    }
} import java.io.BufferedInputStream; BufferedInputStream java.io import java.io.BufferedOutputStream; BufferedOutputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:16-

            int n = sc.nextInt();
            int d = sc.nextInt();
            int[][] vs = new int[n][d];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                }
            }

            int pairs = 0;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                }
            }

            out.println(pairs);
        }
    }

    private static boolean iseven(double val) {
        return val - (int) val == 0;
    }

    private static double dist(int[] a, int[] b) {
        double sum = 0.0;
        for (int i = 0; i < a.length; i++) {
            int t = a[i] - b[i];
            sum += t * t;
        }
        return Math.sqrt(sum);
    }
} Main public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:16-

            int n = sc.nextInt();
            int d = sc.nextInt();
            int[][] vs = new int[n][d];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                }
            }

            int pairs = 0;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                }
            }

            out.println(pairs);
        }
    } main {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:16-

            int n = sc.nextInt();
            int d = sc.nextInt();
            int[][] vs = new int[n][d];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                }
            }

            int pairs = 0;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                }
            }

            out.println(pairs);
        }
    } try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:16-

            int n = sc.nextInt();
            int d = sc.nextInt();
            int[][] vs = new int[n][d];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                }
            }

            int pairs = 0;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                }
            }

            out.println(pairs);
        } {

            Scanner sc = new Scanner(in);

            // 10:16-

            int n = sc.nextInt();
            int d = sc.nextInt();
            int[][] vs = new int[n][d];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                }
            }

            int pairs = 0;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                }
            }

            out.println(pairs);
        } BufferedInputStream in = new BufferedInputStream(System.in) BufferedInputStream in = new BufferedInputStream(System.in) new BufferedInputStream(System.in) PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)) PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)) new PrintWriter(new BufferedOutputStream(System.out)) Scanner sc = new Scanner(in); sc new Scanner(in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int d = sc.nextInt(); d sc.nextInt() sc.nextInt sc int[][] vs = new int[n][d]; vs new int[n][d] n d for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                }
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                }
            } {
                for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                }
            } for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                } int j = 0; int j = 0; j 0 j < d j d j++ j++ j {
                    vs[i][j] = sc.nextInt();
                } {
                    vs[i][j] = sc.nextInt();
                } vs[i][j] = sc.nextInt() vs[i][j] vs[i] vs i j sc.nextInt() sc.nextInt sc int pairs = 0; pairs 0 for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                }
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                }
            } {
                for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                }
            } for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                } int j = i + 1; int j = i + 1; j i + 1 i 1 j < n j n j++ j++ j {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                } {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                } if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    } iseven(dist(vs[i], vs[j])) iseven dist(vs[i], vs[j]) dist vs[i] vs i vs[j] vs j {
                        pairs++;
                    } pairs++ pairs out.println(pairs) out.println out pairs String[] args args private static boolean iseven(double val) {
        return val - (int) val == 0;
    } iseven {
        return val - (int) val == 0;
    } return val - (int) val == 0; val - (int) val == 0 val - (int) val val (int) val 0 double val val private static double dist(int[] a, int[] b) {
        double sum = 0.0;
        for (int i = 0; i < a.length; i++) {
            int t = a[i] - b[i];
            sum += t * t;
        }
        return Math.sqrt(sum);
    } dist {
        double sum = 0.0;
        for (int i = 0; i < a.length; i++) {
            int t = a[i] - b[i];
            sum += t * t;
        }
        return Math.sqrt(sum);
    } double sum = 0.0; sum 0.0 for (int i = 0; i < a.length; i++) {
            int t = a[i] - b[i];
            sum += t * t;
        } int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i {
            int t = a[i] - b[i];
            sum += t * t;
        } {
            int t = a[i] - b[i];
            sum += t * t;
        } int t = a[i] - b[i]; t a[i] - b[i] a[i] a i b[i] b i sum += t * t sum t * t t t return Math.sqrt(sum); Math.sqrt(sum) Math.sqrt Math sum int[] a a int[] b b public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:16-

            int n = sc.nextInt();
            int d = sc.nextInt();
            int[][] vs = new int[n][d];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                }
            }

            int pairs = 0;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                }
            }

            out.println(pairs);
        }
    }

    private static boolean iseven(double val) {
        return val - (int) val == 0;
    }

    private static double dist(int[] a, int[] b) {
        double sum = 0.0;
        for (int i = 0; i < a.length; i++) {
            int t = a[i] - b[i];
            sum += t * t;
        }
        return Math.sqrt(sum);
    }
} public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:16-

            int n = sc.nextInt();
            int d = sc.nextInt();
            int[][] vs = new int[n][d];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                }
            }

            int pairs = 0;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                }
            }

            out.println(pairs);
        }
    }

    private static boolean iseven(double val) {
        return val - (int) val == 0;
    }

    private static double dist(int[] a, int[] b) {
        double sum = 0.0;
        for (int i = 0; i < a.length; i++) {
            int t = a[i] - b[i];
            sum += t * t;
        }
        return Math.sqrt(sum);
    }
} Main
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:16-

            int n = sc.nextInt();
            int d = sc.nextInt();
            int[][] vs = new int[n][d];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                }
            }

            int pairs = 0;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                }
            }

            out.println(pairs);
        }
    }

    private static boolean iseven(double val) {
        return val - (int) val == 0;
    }

    private static double dist(int[] a, int[] b) {
        double sum = 0.0;
        for (int i = 0; i < a.length; i++) {
            int t = a[i] - b[i];
            sum += t * t;
        }
        return Math.sqrt(sum);
    }
}
