Created
March 7, 2017 23:42
-
-
Save rjshekar90/be9926c529adf16507aad0c2940d9dd4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product | |
k, m = map(int, input().split()) | |
arrays = [list(map(int, input().split()[1:])) for _ in range(k)] | |
lst = [] | |
for a in list(product(*arrays)): | |
lst.append(sum([b ** 2 for b in a]) % m) | |
print(max(lst)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment