# Path: tryalgo/freivalds.py
# def freivalds(A, B, C):
#     """Tests matrix product AB=C by Freivalds
# 
#     :param A: n by n numerical matrix
#     :param B: same
#     :param C: same
#     :returns: False with high probability if AB != C
# 
#     :complexity:
#         :math:`O(n^2)`
#     """
#     n = len(A)
#     x = [randint(0, 1000000) for j in range(n)]
#     return mult(A, mult(B, x)) == mult(C, x)
# 
# def readint():
#     """
#     function to read an integer from stdin
#     """
#     return int(stdin.readline())
# 
# def readmatrix(n):
#     """
#     function to read a matrix
#     """
#     M = []
#     for _ in range(n):
#         row = readarray(int)
#         assert len(row) == n
#         M.append(row)
#     return M
# 
# def readarray(typ):
#     """
#     function to read an array
#     """
#     return list(map(typ, stdin.readline().split()))


import unittest
    from unittest.mock import patch
    from mock import patch
from tryalgo.freivalds import freivalds, readint, readmatrix, readarray
# coding: utf8
# jill-jênn vie et christoph dürr - 2020

# pylint: disable=missing-docstring
try:
except ImportError:


class TestNextPermutation(unittest.TestCase):

    def test_freivalds(self):
        A = [[2, 3], [3, 4]]
        B = [[1, 0], [1, 2]]
        C = [[5, 6], [7, 8]]
        self.assertTrue(freivalds(A, B, C))
        # [!] might fail with small probability

    def test_readint(self):
        with patch('sys.stdin.readline', return_value="1"):
            self.assertEqual(readint(), 1)

    def test_readarray(self):
        with patch('sys.stdin.readline', return_value="1 2 3"):
            self.assertEqual(readarray(int), [1, 2, 3])

    def test_readmatrix(self):
        with patch('sys.stdin.readline', return_value="1 2 3"):

# Path: tryalgo/freivalds.py
# def freivalds(A, B, C):
#     """Tests matrix product AB=C by Freivalds
# 
#     :param A: n by n numerical matrix
#     :param B: same
#     :param C: same
#     :returns: False with high probability if AB != C
# 
#     :complexity:
#         :math:`O(n^2)`
#     """
#     n = len(A)
#     x = [randint(0, 1000000) for j in range(n)]
#     return mult(A, mult(B, x)) == mult(C, x)
# 
# def readint():
#     """
#     function to read an integer from stdin
#     """
#     return int(stdin.readline())
# 
# def readmatrix(n):
#     """
#     function to read a matrix
#     """
#     M = []
#     for _ in range(n):
#         row = readarray(int)
#         assert len(row) == n
#         M.append(row)
#     return M
# 
# def readarray(typ):
#     """
#     function to read an array
#     """
#     return list(map(typ, stdin.readline().split()))


# Path: tests/test_freivalds.py
import unittest
    from unittest.mock import patch
    from mock import patch
from tryalgo.freivalds import freivalds, readint, readmatrix, readarray

# coding: utf8
# jill-jênn vie et christoph dürr - 2020

# pylint: disable=missing-docstring
try:
except ImportError:


class TestNextPermutation(unittest.TestCase):

    def test_freivalds(self):
        A = [[2, 3], [3, 4]]
        B = [[1, 0], [1, 2]]
        C = [[5, 6], [7, 8]]
        self.assertTrue(freivalds(A, B, C))
        # [!] might fail with small probability

    def test_readint(self):
        with patch('sys.stdin.readline', return_value="1"):
            self.assertEqual(readint(), 1)

    def test_readarray(self):
        with patch('sys.stdin.readline', return_value="1 2 3"):
            self.assertEqual(readarray(int), [1, 2, 3])

    def test_readmatrix(self):
        with patch('sys.stdin.readline', return_value="1 2 3"):

            self.assertEqual(readmatrix(3), [[1, 2, 3], [1, 2, 3], [1, 2, 3]])