Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys

def dec_num(x):
    for i in range(len(x)):
        if x[i] == 2:
            x[i] = 5
        elif x[i] == 3:
            x[i] = 10
        elif x[i] == 4:
            x[i] = 50
        elif x[i] == 5:
            x[i] = 100
        elif x[i] == 6:
            x[i] = 500
        elif x[i] == 7:
            x[i] = 1000

def to_index(x):
    if x == 1:
        return 1
    elif x == 5:
        return 2
    elif x == 10:
        return 3
    elif x == 50:
        return 4
    elif x == 100:
        return 5
    elif x == 500:
        return 6
    elif x == 1000:
        return 7


def toNum(x):
    result = 0
    tmp = x[0]
    for i in range(len(x)):
        if tmp < x[i]:
            result += x[i]-tmp
        elif i <= len(x) and x[i] < x[i+1]:
            result += 0
        else:
            result += x[i]
        tmp = x[i] 

    return result

for line in sys.stdin.readlines():
    line = line.translate(str.maketrans('IVXLCDM', '1234567'))
    num = list(map(int, (' '.join(line)).split()))
    dec_num(num)
    print(toNum(num))

Fixed submission:
import sys

def dec_num(x):
    for i in range(len(x)):
        if x[i] == 2:
            x[i] = 5
        elif x[i] == 3:
            x[i] = 10
        elif x[i] == 4:
            x[i] = 50
        elif x[i] == 5:
            x[i] = 100
        elif x[i] == 6:
            x[i] = 500
        elif x[i] == 7:
            x[i] = 1000

def to_index(x):
    if x == 1:
        return 1
    elif x == 5:
        return 2
    elif x == 10:
        return 3
    elif x == 50:
        return 4
    elif x == 100:
        return 5
    elif x == 500:
        return 6
    elif x == 1000:
        return 7


def toNum(x):
    result = 0
    tmp = x[0]
    for i in range(len(x)):
        if tmp < x[i]:
            result += x[i]-tmp
        elif i < len(x)-1 and x[i] < x[i+1]:
            result += 0
        else:
            result += x[i]
        tmp = x[i] 

    return result

for line in sys.stdin.readlines():
    line = line.translate(str.maketrans('IVXLCDM', '1234567'))
    num = list(map(int, (' '.join(line)).split()))
    dec_num(num)
    print(toNum(num))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
for n in sys.stdin:
    a=int(n.strip())
    b=a
    while 1:
        a+=2
        if is_prime(a):
            max_a=a
            break
    while 1:
        b-=2
        if is_prime(b):
            min_b=b
            break
    print min_b,max_a

Fixed submission:
import sys
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
for n in sys.stdin:
    a=int(n.strip())
    b=a
    while 1:
        a+=1
        if is_prime(a):
            max_a=a
            break
    while 1:
        b-=1
        if is_prime(b):
            min_b=b
            break
    print min_b,max_a

Buggy python submission (verdict: Runtime Error):
import sys
def is_prime(q):
&#160;&#160;&#160;&#160;q = abs(q)
&#160;&#160;&#160;&#160;if q == 2: return True
&#160;&#160;&#160;&#160;if q < 2 or q&1 == 0: return False
&#160;&#160;&#160;&#160;return pow(2, q-1, q) == 1
for n in sys.stdin:
&#160;&#160;&#160;&#160;a=int(n.strip())
&#160;&#160;&#160;&#160;b=a
&#160;&#160;&#160;&#160;while 1:
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;a+=2
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if is_prime(a):
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;max_a=a
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;break
&#160;&#160;&#160;&#160;while 1:
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;b-=2
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if is_prime(b):
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;min_b=b
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;break
&#160;&#160;&#160;&#160;print min_b,max_a

Fixed submission:
import sys
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
for n in sys.stdin:
    a=int(n.strip())
    b=a
    while 1:
        a+=1
        if is_prime(a):
            max_a=a
            break
    while 1:
        b-=1
        if is_prime(b):
            min_b=b
            break
    print min_b,max_a
Buggy python submission (verdict: Runtime Error):
nums = []
while True:
    n = raw_input()
    if not n: break
    nums.append(int(n))
nums.sort(reverse=True)
for i in range(3): print nums[i]

Fixed submission:
nums = []
while True:
    try:
        nums.append(int(raw_input()))
    except (EOFError):
        break
nums.sort(reverse=True)
for i in range(3): print nums[i]
Buggy python submission (verdict: Time Limit Exceeded):
def sieve(n):
    a = [1 for i in range(n + 1)]
    for i in range(2, n + 1):
        if a[i]:
            for j in range(2 * i, n + 1, i):
                a[j] = 0
    return a[2:]

while True:
    try:
        n = int(raw_input())
        print len(filter(lambda x: x, sieve(n)))
    except (EOFError):
        break

Fixed submission:
def sieve(n):
    a = [1] * (n + 1)
    for i in range(2, n):
        if i * i > n: break
        if a[i]:
            for j in range(2 * i, n + 1, i):
                a[j] = 0
    return a[2:]

while True:
    try:
        n = int(raw_input())
        print len(filter(lambda x: x, sieve(n)))
    except (EOFError):
        break
Buggy python submission (verdict: Runtime Error):
while True:
    n = int(raw_input())
    if n == 0: break
    
    a = []
    for i in range(n):
        a.append(map(int, raw_input().split()))
    
    for i in range(n):
        a[i].append(sum(a[i]))
    
    col_sum = []
    for col in range(len(a[0])):
        sum = 0
        for row in range(len(a)):
            sum += a[row][col];
        col_sum.append(sum)
    a.append(col_sum)

    for row in range(len(a)):
        for col in range(len(a[0])):
            print "%5d" % a[row][col],
        print

Fixed submission:
import sys

while True:
    n = int(raw_input())
    if n == 0: break
    
    a = []
    for i in range(n):
        a.append(map(int, raw_input().split()))
    
    for i in range(n):
        a[i].append(sum(a[i]))
    
    col_sum = []
    for col in range(len(a[0])):
        s = 0
        for row in range(len(a)):
            s += a[row][col];
        col_sum.append(s)
    a.append(col_sum)

    for row in range(len(a)):
        for col in range(len(a[0])):
            sys.stdout.write("%5d" % a[row][col])
        print
Buggy python submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())

if a > b:
	print "a > b"
elif a < b:
	print "a < b"
else
	print "a == b"

Fixed submission:
a, b = map(int, raw_input().split())

if a > b:
	print 'a > b'
elif a < b:
	print 'a < b'
else:
	print 'a == b'

Buggy python submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())

if a > b:
	print 'a > b'
elif a < b:
	print 'a < b'
else
	print 'a == b'

Fixed submission:
a, b = map(int, raw_input().split())

if a > b:
	print 'a > b'
elif a < b:
	print 'a < b'
else:
	print 'a == b'

Buggy python submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())

if a > b:
	print 'a > b'
elif a < b:
	print 'a < b'
else
	print 'a == b'

Fixed submission:
a, b = map(int, raw_input().split())

if a > b:
	print 'a > b'
elif a < b:
	print 'a < b'
else:
	print 'a == b'
Buggy python submission (verdict: Time Limit Exceeded):
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
import sys

for line in sys.stdin:
    small, large = sorted(int(n) for n in line .split())
    for i in xrange(small, 0, -1):
        if large % i == 0 and small % i == 0:
            gcd = i
            break
    for i in xrange(2, large + 1):
        if i * small % large == 0:
            lcm = i * small
            break
    print(gcd, lcm)

Fixed submission:
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
import sys
from fractions import gcd

for line in sys.stdin:
    small, large = sorted(int(n) for n in line .split())
    G = gcd(large, small)
    print(G, large // G * small)

Buggy python submission (verdict: Time Limit Exceeded):
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
import sys

for line in sys.stdin:
    small, large = sorted(int(n) for n in line .split())
    for i in (n for n in xrange(small, 0, -1) if not small % n):
        if not large % i:
            gcd = i
            break
    for i in xrange(2, small + 1):
        if not i * large % small:
            lcm = i * large
            break
    print(gcd, lcm)

Fixed submission:
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
import sys
from fractions import gcd

for line in sys.stdin:
    small, large = sorted(int(n) for n in line .split())
    G = gcd(large, small)
    print(G, large // G * small)
Buggy python submission (verdict: Time Limit Exceeded):
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def enum_prime(n):
    if n < 2:
        return []
    if n == 2:
        return [2]
    L = list(range(2, n + 1))
    PL = []
    while True:
        PL.append(L[0])
        L = [i for i in L if i % PL[-1] != 0]
        if L[-1] < PL[-1] ** 2:
            return PL + L

for line in stdin:
    print(len(enum_prime(int(line))))

Fixed submission:
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def enum_prime(n):
    if n < 2:
        return []
    if n == 2:
        return [2]
    L = list(range(2, n + 1))
    PL = []
    while True:
        PL.append(L[0])
        L = [i for i in L if i % PL[-1] != 0]
        if L[-1] < PL[-1] ** 2:
            return PL + L

primelist = enum_prime(999999)
for line in stdin:
    n = int(line)
    cnt = 0
    for p in primelist:
        if n < p:
            break
        cnt += 1
    print(cnt)
Buggy python submission (verdict: Runtime Error):
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

L = []
for line in stdin:
    n = int(line)
    if not n:
        print(L.pop())
    else:
        L.append(n)

Fixed submission:
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

L = []
for line in stdin:
    if not line.strip():
        continue
    n = int(line)
    if not n:
        print(L.pop())
    else:
        L.append(n)
Buggy python submission (verdict: Runtime Error):
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin

def gradient(x1, y1, x2, y2):
    return (y1 - y2) / (x1 - x2)

for n in xrange(int(stdin.readline())):
    p = [float(s) for s in stdin.readline().split()]
    if gradient(*p[:4]) == gradient(*p[4:]):
        print('YES')
    else:
        print('NO')

Fixed submission:
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin

def gradient(x1, y1, x2, y2):
    if x1 - x2 == 0.0:
        return float('inf')
    return (y1 - y2) / (x1 - x2)

for n in xrange(int(stdin.readline())):
    p = [float(s) for s in stdin.readline().split()]
    if gradient(*p[:4]) == gradient(*p[4:]):
        print('YES')
    else:
        print('NO')
Buggy python submission (verdict: Runtime Error):
#include <stdio.h>
const char WEEKDAYS[7][10] = {
	"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
	"Sunday"
};
const int MONTHS_1ST_WEEKDAY[] = {
	3, 6, 0, 3, 5, 1, 3, 6, 2, 4, 0, 2
};

int main() {
	int month, day;
	while (1) {
		scanf(" %d %d", &month, &day);
		if (month == 0 && day == 0)
			break;
		puts(WEEKDAYS[(MONTHS_1ST_WEEKDAY[month-1] + day - 1) % 7]);
	}
	return 0;
}

Fixed submission:
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin
from datetime import date

for line in stdin:
    if line.startswith('0 0'):
        break
    print(date(2004, *(int(s) for s in line.split())).strftime('%A'))
Buggy python submission (verdict: Runtime Error):
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from collections import namedtuple
Point = namedtuple('Point', 'x y')

def make_test(p1, p2):
    gradient = (p1.y - p2.y) / (p1.x - p2.x)
    y_intercept = p1.y - gradient * p1.x
    return lambda p: gradient * p.x + y_intercept > p.y

for line in stdin:
    it = (float(s) for s in line.split(','))
    A, B, C, D = (Point(next(it), next(it)) for _ in xrange(4))

    f = make_test(A, C)
    g = make_test(B, D)
    if f(B) == f(D) or g(A) == g(C):
        print('NO')
    else:
        print('YES')

Fixed submission:
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from collections import namedtuple
Point = namedtuple('Point', 'x y')

def make_test(p1, p2):
    if p1.x == p2.x:
        gradient = p1.x
        return lambda p: gradient > p.x
    gradient = (p1.y - p2.y) / (p1.x - p2.x)
    y_intercept = p1.y - gradient * p1.x
    return lambda p: gradient * p.x + y_intercept > p.y

for line in stdin:
    it = (float(s) for s in line.split(','))
    A, B, C, D = (Point(next(it), next(it)) for _ in xrange(4))

    f = make_test(A, C)
    g = make_test(B, D)
    if f(B) == f(D) or g(A) == g(C):
        print('NO')
    else:
        print('YES')
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)

from sys import stdin
from string import ascii_lowercase
from itertools import count

def gcd(m, n):
    m, n = sorted([m, n])
    while n:
        m, n = n, m % n
    return m

def encode(char, A, B):
    return chr(((A * (ord(char) - 97) + B) % 26) + 97)

def solve(words):
    for a in (i for i in count(0) if gcd(i, 26) == 1):
        for b in range(26):
            for word in words:
                that = ''.join(encode(c, a, b) for c in 'that')
                if word == that:
                    return (a, b)
                this = ''.join(encode(c, a, b) for c in 'this')
                if word == this:
                    return (a, b)

def main():
    for _ in range(int(stdin.readline())):
        line = stdin.readline()
        a, b = solve([s for s in line.split() if len(s) == 4])
        d = {encode(c, a, b): c for c in ascii_lowercase}
        d[b' '] = b' '
        print(''.join(d[c] for c in line))

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)

from sys import stdin
from string import ascii_lowercase
from itertools import count

def gcd(m, n):
    m, n = sorted([m, n])
    while n:
        m, n = n, m % n
    return m

def encode(char, A, B):
    return chr(((A * (ord(char) - 97) + B) % 26) + 97)

def solve(words):
    for a in (i for i in count(0) if gcd(i, 26) == 1):
        for b in range(26):
            for word in words:
                that = ''.join(encode(c, a, b) for c in 'that')
                if word == that:
                    return (a, b)
                this = ''.join(encode(c, a, b) for c in 'this')
                if word == this:
                    return (a, b)

def main():
    for _ in range(int(stdin.readline())):
        line = stdin.readline()
        a, b = solve([s for s in line.split() if len(s) == 4])
        d = {encode(c, a, b): c for c in ascii_lowercase}
        d[b' '] = b' '
        d[b'\n'] = ''
        print(''.join(d[c] for c in line))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def solve(li, n, s, total, cnt):
    for i in li:
        value = i * n + total
        if value > s:
            break
        if n > 1:
            a = li[:]
            a.remove(i)
            solve(a, n - 1, s, value, cnt)
        elif value == s:
            cnt[0] += 1

for line in stdin:
    n, s = (int(s) for s in line.split())

    cnt = [0]
    solve(list(range(10)), n, s, 0, cnt)
    print(cnt[0])

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def solve(li, n, s, total, cnt):
    for i in li:
        value = i * n + total
        if value > s:
            break
        if n - 1:
            subli = li[:]
            subli.remove(i)
            r = range(n - 1, 0, -1)
            minimum = value + sum(i * j for i, j in zip(r, subli))
            maximum = value + sum(i * j for i, j in zip(r, subli[::-1]))
            if minimum <= s <= maximum: 
                solve(subli, n - 1, s, value, cnt)
        elif value == s:
            cnt[0] += 1
            break

cnt = [0]
for line in stdin:
    n, s = (int(s) for s in line.split())
    cnt[0] = 0

    solve(list(range(10)), n, s, 0, cnt)
    print(cnt[0])
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from collections import Counter

cnt = Counter()
for line in stdin:
    start, end = (int(s) for s in line.split())
    if start or end:
        cnt[start] += 1
        cnt[end] += 1
    else:
        assert cnt[1] == 1
        assert cnt[2] == 1
        eulerian_graph = sum(i % 2 for i in cnt.values()) == 2
        print('OK' if eulerian_graph else 'NG')
        cnt.clear()

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from collections import Counter

cnt = Counter()
for line in stdin:
    start, end = (int(s) for s in line.split())
    if start or end:
        cnt[start] += 1
        cnt[end] += 1
    else:
        semi_eulerian = sum(i % 2 for i in cnt.values()) == 2
        if semi_eulerian and cnt[1] % 2 and cnt[2] % 2:
            print('OK')
        else:
            print('NG')
        cnt.clear()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    stack = []
    for s in line.split():
        if s.isdigit():
            stack.append(float(s))
        elif s == '+':
            n = stack.pop()
            stack[-1] += n
        elif s == '-':
            n = stack.pop()
            stack[-1] -= n
        elif s == '*':
            n = stack.pop()
            stack[-1] *= n
        elif s == '/':
            n = stack.pop()
            stack[-1] /= n
    print('{:.6f}'.format(stack[-1]))

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
import re

for line in stdin:
    stack = []
    for s in line.split():
        if re.match('[-+]?\d+', s):
            stack.append(float(s))
        elif s == '+':
            n = stack.pop()
            stack[-1] += n
        elif s == '-':
            n = stack.pop()
            stack[-1] -= n
        elif s == '*':
            n = stack.pop()
            stack[-1] *= n
        elif s == '/':
            n = stack.pop()
            stack[-1] /= n
    print('{:.6f}'.format(stack[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit
from itertools import combinations


def count(n, s):
    count = 0
    for a in combinations(range(101), n):
        if sum(a) == s:
            count += 1
    return count


def main(readline=stdin.readline):
    for line in stdin:
        n, s = (int(s) for s in line.split())
        if not n and not s:
            exit()
        print(count(n, s))


if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def make_number_of_combination():
    pre = [[0] * 10 for _ in xrange(1001)]
    now = [[0] * 10 for _ in xrange(1001)]

    for a in xrange(101):
        now[a][0] = 1
        for i in xrange(1001):
            if i+a > 1000:
                break
            for j in xrange(9):
                now[i+a][j+1] += pre[i][j]

        for i in xrange(1001):
            for j in xrange(10):
                pre[i][j] = now[i][j]

    return pre


def main():
    ans = make_number_of_combination()
    for line in stdin:
        n, s = (int(s) for s in line.split())
        if not n and not s:
            exit()
        print(ans[s][n-1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def main():
    num_mat = int(stdin.readline())
    data = [int(s) for s in stdin.readline().split()]
    for _ in range(num_mat-1):
        _, row = (int(s) for s in stdin.readline().split())
        data.append(row)
    num_dat = len(data)

    bin_op = tuple(data[i]*data[i+1]*data[i+2] for i in range(num_dat-2))
    parts = [(data[0]*data[1], data[-2]*data[-1]), bin_op]

    for j in range(3, num_mat):
        part = parts[-1]
        new_part = []
        for i in range(num_dat-j):
            a = data[i]
            b = data[i+1]
            c = data[i+j-1]
            d = data[i+j]
            new_part.append(min(part[i] + a*c*d, part[i+1] + a*b*d))
        parts.append(new_part)

    L = data
    print(min(parts[i][0] + parts[-(i+1)][-1] +
              L[0]*L[i+1]*L[-1] for i in range(len(parts))))


main()

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def main():
    num_mat = int(stdin.readline())
    r = [int(s) for s in stdin.readline().split()]
    for _ in range(num_mat-1):
        _, row = (int(s) for s in stdin.readline().split())
        r.append(row)

    if num_mat < 2:
        print(0)
        return
    elif num_mat < 3:
        print(r[0]*r[1]*r[2])
        return

    M = []
    M.append([0] * num_mat)
    M.append([r[i]*r[i+1]*r[i+2] for i in range(len(M[-1])-1)])

    for i in range(2, num_mat):
        N = []
        for j in range(num_mat-i):
            N.append(min(M[k][j]+M[i-1-k][1+j+k]+r[j]*r[1+j+k]*r[i+1+j]
                         for k in range(i)))
        M.append(N)
    print(M[-1][0])


main()
Buggy python submission (verdict: Runtime Error):
#include <stdio.h>
int main(void) {
	int num, i, k, u;
	int v[101];
	const char *fmt;

	scanf("%d", &num);
	for (i = 0; i < num; i++) {
		for (k = 1; k <= num; k++) {
			v[k] = 0;
		}
		scanf("%d %d", &u, &k);
		while (k--) {
			scanf("%d", &u);
			v[u] = 1;
		}
		fmt = "%d";
		for (k = 1; k <= num; k++) {
			printf(fmt, v[k]);
			fmt = " %d";
		}
		putchar('\n');
	}
	return 0;
}

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def main():
    num = int(stdin.readline())

    for _ in xrange(num):
        L = [int(s) for s in stdin.readline().split()][2:]
        print(*(int(i in L) for i in xrange(1, num+1)))


main()