Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
while True:
  x, y = map(int, raw_input.split())
  if x == 0 and y == 0:
    break
  elif x < y:
    print "%d %d" %(x, y)
  else:
    print "%d %d" %(y, x)

Fixed submission:
while True:
  x, y = map(int, raw_input().split())
  if x == 0 and y == 0:
    break
  elif x < y:
    print "%d %d" %(x, y)
  else:
    print "%d %d" %(y, x)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())
c = double(a)
d = double(b)

print "%d %d %.5f" %(a/b, a%b, c/d)

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

print "%d %d %.5f" %(a/b, a%b, c/d)
Buggy python submission (verdict: Runtime Error):
n = input()
for i in range(n):
  a = raw_input().split()

min = a[0]
max = a[0]
sum = a[0]

for num in a
  if num > max:
    max = num
  if num < min:
    min = num
  sum += num 

print ("%d %d %d") %(min, max, sum)

Fixed submission:
n = input()

a = map(int, raw_input().split())

print ("%d %d %d") %(min(a), max(a), sum(a))

Buggy python submission (verdict: Runtime Error):
n = input()

a = raw_input().split()

min = a[0]
max = a[0]
sum = a[0]

for num in range(len(a-1))
  if num > max:
    max = num
  if num < min:
    min = num
  sum += num 

print ("%d %d %d") %(min, max, sum)

Fixed submission:
n = input()

a = map(int, raw_input().split())

print ("%d %d %d") %(min(a), max(a), sum(a))
Buggy python submission (verdict: Runtime Error):
while true:
  H, W = map(int, raw_input().split())
  for i in range(H):
    width = ''
    for j in range(W):
      width += '#'
    print width
  print ''

Fixed submission:
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    width = ""
    for j in range(W):
      width += "#"
    print width
  print ""

Buggy python submission (verdict: Runtime Error):
while true:
  H, W = map(int, raw_input().split())
  for i in range(H):
    width = ""
    for j in range(W):
      width += "#"
    print width
  print ""

Fixed submission:
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    width = ""
    for j in range(W):
      width += "#"
    print width
  print ""

Buggy python submission (verdict: Runtime Error):
while True:
  H, W = map(int, raw_input().split())
  for i in range(H):
    width = ""
    for j in range(W):
      width += "#"
    print width
  print ""

Fixed submission:
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    width = ""
    for j in range(W):
      width += "#"
    print width
  print ""
Buggy python submission (verdict: Runtime Error):
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    width = "#"
    if i == 0 or i == H - 1:
      for j in range(1,W):
        width += "#"
      print width
    else:
       for j in range(1,W-1):
        width += "."
      width += "#"
      print width
  print ""

Fixed submission:
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  print "#"*W
  for i in range(H-2):
    if W > 2:
      print "#" + "."*(W-2) + "#"
    else:
      print "#"*W 
  print "#"*W
  print ""

Buggy python submission (verdict: Runtime Error):
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    width = "#"
    if i == 0 or i == H - 1:
      for j in range(W-1):
        width += "#"
      print width
    else:
       for j in range(W-2):
        width += "."
      width += "#"
      print width
  print ""

Fixed submission:
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  print "#"*W
  for i in range(H-2):
    if W > 2:
      print "#" + "."*(W-2) + "#"
    else:
      print "#"*W 
  print "#"*W
  print ""

Buggy python submission (verdict: Runtime Error):
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  print "#"*W
  for i in range(H-1):
    print "#" + "."*(W-2) + "#"
  print "#"*W
 print ""

Fixed submission:
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  print "#"*W
  for i in range(H-2):
    if W > 2:
      print "#" + "."*(W-2) + "#"
    else:
      print "#"*W 
  print "#"*W
  print ""

Buggy python submission (verdict: Runtime Error):
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  print ("#"*W)
  for i in range(H-1):
    print ("#" + "."*(W-2) + "#")
  print ("#"*W)
 print ""

Fixed submission:
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  print "#"*W
  for i in range(H-2):
    if W > 2:
      print "#" + "."*(W-2) + "#"
    else:
      print "#"*W 
  print "#"*W
  print ""

Buggy python submission (verdict: Runtime Error):
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  print "#"*W
  for i in range(H-1):
    if W > 2:
      print "#" + "."*(W-2) + "#"
    else:
      print "#"*W 
  print "#"*W
 print ""

Fixed submission:
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  print "#"*W
  for i in range(H-2):
    if W > 2:
      print "#" + "."*(W-2) + "#"
    else:
      print "#"*W 
  print "#"*W
  print ""
Buggy python submission (verdict: Runtime Error):
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    if H /2 == 0:
      if W/2 == 0:
        print "#."*(W/2)
      else:
        print "#."*(W/2) + "#"
    else:
      if W/2 == 0:
        print ".""*(W/2)
      else:
        print ".#"*(W/2) + "."
  print ""

Fixed submission:
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    if i%2 == 0:
      if W%2 == 0:
        print "#."*(W/2)
      else:
        print "#."*(W/2) + "#"
    else:
      if W%2 == 0:
        print ".#"*(W/2)
      else:
        print ".#"*(W/2) + "."
  print ""
Buggy python submission (verdict: Runtime Error):
n = input()

print ,
for i in xrange(1, n+1):
    if i % 3 == 0 or i % 10 == 3:
        print i,

Fixed submission:
n = input()

print '',
for i in xrange(1, n+1):
    x = i
    if x % 3 == 0:
        print i,
    else:
        while x:
            if x % 10 == 3:
                print i,
                break
            x /= 10
Buggy python submission (verdict: Runtime Error):
def main():
    num = int(stdin.readline())
 
    for _ in xrange(num):
        x = stdin.readline().rstrip()
        y = stdin.readline().rstrip()
 
        n = len(y) + 1
 
        cim1 = [0] * n
        for i, xi in enumerate(x, start=1):
            ci = [0] * n
            for j, yj in enumerate(y, start=1):
                if xi == yj:
                    ci[j] = cim1[j-1] + 1
                elif cim1[j] >= ci[j-1]:
                    ci[j] = cim1[j]
                else:
                    ci[j] = ci[j-1]
            cim1 = ci
 
       print(ci[j])
 
 
main()

Fixed submission:
def solve():
    a1 = raw_input()
    a2 = raw_input()
    a = len(a1)
    b = len(a2)
    c1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = a1[i]
        c2 = c1+[]
        for j in range(b):
            if e1 == a2[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
 
n = input()
for i2 in range(n):
    print solve()

Buggy python submission (verdict: Runtime Error):
import itertools

q = int(input())
for a in range(q):
    X = input()
    Y = input()
    cost = [0]
    for c in Y:
        for i in range(len(cost) - 1, -1, -1):
            index = X.find(c, cost[i]) + 1
            if index:
                if i + 1 < len(cost):
                    cost[i + 1] = min(cost[i + 1], index)
                else:
                    cost.append(index)
    print(len(cost) - 1)

Fixed submission:
def solve():
    a1 = raw_input()
    a2 = raw_input()
    a = len(a1)
    b = len(a2)
    c1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = a1[i]
        c2 = c1+[]
        for j in range(b):
            if e1 == a2[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
 
n = input()
for i2 in range(n):
    print solve()

Buggy python submission (verdict: Runtime Error):
import sys

q = int(input())
for a in range(q):
    X = input()
    Y = input()
    cost = [0]
    for c in Y:
        for i in range(len(cost) - 1, -1, -1):
            index = X.find(c, cost[i]) + 1
            if index:
                if i + 1 < len(cost):
                    cost[i + 1] = min(cost[i + 1], index)
                else:
                    cost.append(index)
    print(len(cost) - 1)

Fixed submission:
def solve():
    a1 = raw_input()
    a2 = raw_input()
    a = len(a1)
    b = len(a2)
    c1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = a1[i]
        c2 = c1+[]
        for j in range(b):
            if e1 == a2[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
 
n = input()
for i2 in range(n):
    print solve()
Buggy python submission (verdict: Runtime Error):
from __future__ import division, print_function
from sys import stdin, maxint
 
 
def main():
    n = int(stdin.readline())
 
    M = []
    for _ in xrange(n):
        M.append([int(s) for s in stdin.readline().split()])
 
    g = set(xrange(1, num+1))
    index = g.pop()
    h = {index}
    weight = 0
 
    while g:
        minimum = maxint
        for j in h:
            mj = M[j-1]
            for i in g:
                if 0 <= mj[i-1] < minimum:
                    index = i
                    minimum = mj[i-1]
        h.add(index)
        g.remove(index)
        weight += minimum
 
  
 
 
main()

Fixed submission:
from __future__ import division, print_function
from sys import stdin, maxint
 
 
def main():
    num = int(stdin.readline())
 
    M = []
    for _ in xrange(num):
        M.append([int(s) for s in stdin.readline().split()])
 
    g = set(xrange(1, num+1))
    index = g.pop()
    h = {index}
    weight = 0
 
    while g:
        minimum = maxint
        for j in h:
            mj = M[j-1]
            for i in g:
                if 0 <= mj[i-1] < minimum:
                    index = i
                    minimum = mj[i-1]
        h.add(index)
        g.remove(index)
        weight += minimum
 
    print(weight)
 
 
main()

Buggy python submission (verdict: Runtime Error):
from __future__ import division, print_function
from sys import stdin, maxint
 
 
def main():
    n = int(stdin.readline())
 
    M = []
    for _ in xrange(n):
        M.append([int(s) for s in stdin.readline().split()])
 
    g = set(xrange(1, num+1))
    index = g.pop()
    h = {index}
    weight = 0
 
    while g:
        minimum = maxint
        for j in h:
            mj = M[j-1]
            for i in g:
                if 0 <= mj[i-1] < minimum:
                    index = i
                    minimum = mj[i-1]
        h.add(index)
        g.remove(index)
        weight += minimum
 
  
 
 
main()

Fixed submission:
from __future__ import division, print_function
from sys import stdin, maxint
 
 
def main():
    num = int(stdin.readline())
 
    M = []
    for _ in xrange(num):
        M.append([int(s) for s in stdin.readline().split()])
 
    g = set(xrange(1, num+1))
    index = g.pop()
    h = {index}
    weight = 0
 
    while g:
        minimum = maxint
        for j in h:
            mj = M[j-1]
            for i in g:
                if 0 <= mj[i-1] < minimum:
                    index = i
                    minimum = mj[i-1]
        h.add(index)
        g.remove(index)
        weight += minimum
 
    print(weight)
 
 
main()
Buggy python submission (verdict: Runtime Error):
x = raw_input()
X = int(x)
print x*x*x

Fixed submission:
x = raw_input()
x = int(x)

print x * x * x
Buggy python submission (verdict: Runtime Error):
a = raw_input()
b = raw_input()
a = int(a)
b = int(b)
print a*b
print 2a+2b

Fixed submission:
a, b = map(int, raw_input(). split())
print a * b, 2 * (a + b)

Buggy python submission (verdict: Runtime Error):
a = raw_input()
b = raw_input()
a = input(a)
b = input(b)
print a*b 2*a+2*b

Fixed submission:
a, b = map(int, raw_input(). split())
print a * b, 2 * (a + b)

Buggy python submission (verdict: Runtime Error):
a,b = raw_input()
a,b = input(a,b)
print a*b, 2*a+2*b

Fixed submission:
a, b = map(int, raw_input(). split())
print a * b, 2 * (a + b)

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

Fixed submission:
a, b = map(int, raw_input(). split())
print a * b, 2 * (a + b)
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

for a<b :
  print a < b

for b<a :
  print b < a

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'
elif a==b:
  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
elif a == b :
   print a==b

Fixed submission:
a, b = map(int, raw_input().split())
  
if a>b:
  print 'a > b'
elif a<b:
  print 'a < b'
elif a==b:
  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
elif a = b :
   print a==b

Fixed submission:
a, b = map(int, raw_input().split())
  
if a>b:
  print 'a > b'
elif a<b:
  print 'a < b'
elif a==b:
  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
elif a == b :
   print a=b

Fixed submission:
a, b = map(int, raw_input().split())
  
if a>b:
  print 'a > b'
elif a<b:
  print 'a < b'
elif a==b:
  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
elif a == b :
   print a=b

Fixed submission:
a, b = map(int, raw_input().split())
  
if a>b:
  print 'a > b'
elif a<b:
  print 'a < b'
elif a==b:
  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
elif a == b :
   print a=b

Fixed submission:
a, b = map(int, raw_input().split())
  
if a>b:
  print 'a > b'
elif a<b:
  print 'a < b'
elif a==b:
  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"
elif a == b :
   print "a==b"

Fixed submission:
a, b = map(int, raw_input().split())
  
if a>b:
  print 'a > b'
elif a<b:
  print 'a < b'
elif a==b:
  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'
elif a == b :
   print 'a==b'

Fixed submission:
a, b = map(int, raw_input().split())
  
if a>b:
  print 'a > b'
elif a<b:
  print 'a < b'
elif a==b:
  print 'a == b'
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, raw_input().split())

if  a < b < c :
    print Yes
else 
    print  No

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

if  a < b < c :
    print 'Yes'
else :
    print  'No'
Buggy python submission (verdict: Runtime Error):
import ans1
import ans2
 
r = float(ans1.stdin.readline())

Fixed submission:
import sys
import math
 
r = float(sys.stdin.readline())
print('%.5f %.5f' % (r**2 * math.pi, r*2 * math.pi))

Buggy python submission (verdict: Runtime Error):
import ans1
import ans2
 
r = float(ans1.stdin.readline())

Fixed submission:
import sys
import math
 
r = float(sys.stdin.readline())
print('%.5f %.5f' % (r**2 * math.pi, r*2 * math.pi))

Buggy python submission (verdict: Runtime Error):
import ans1
import ans2
 
r = float(ans1.stdin.readline())
print('%.5f %.5f' % (r**2 * ans2.pi, r*2 * ans2.pi))

Fixed submission:
import sys
import math
 
r = float(sys.stdin.readline())
print('%.5f %.5f' % (r**2 * math.pi, r*2 * math.pi))
Buggy python submission (verdict: Runtime Error):
def chess(h,w):
    o = ""
    for i in range(h):
        for j in range(w):
            if (i+j)%2: o+="."
            else: o+="#"
        o+="\n
 
while 1:
    h,w=map(int,raw_input().split())
    if h==w==0:break
    chess(h,w)

Fixed submission:
def chess(h,w):
    o = ""
    for i in range(h):
        for j in range(w):
            if (i+j)%2: o+="."
            else: o+="#"
        o+="\n"
    print o
 
while 1:
    h,w=map(int,raw_input().split())
    if h==w==0:break
    chess(h,w)

Buggy python submission (verdict: Runtime Error):
def chess(h,w):
    o = ""
    for i in range(h):
        for j in range(w):
            if (i+j)%2: o+="."
            else: o+="#"
        o+="\n
 
while 1:
    h,w=map(int,raw_input().split())
    if h==w==0:break
    chess(h,

Fixed submission:
def chess(h,w):
    o = ""
    for i in range(h):
        for j in range(w):
            if (i+j)%2: o+="."
            else: o+="#"
        o+="\n"
    print o
 
while 1:
    h,w=map(int,raw_input().split())
    if h==w==0:break
    chess(h,w)
Buggy python submission (verdict: Runtime Error):
input()
l = raw_input().split()
print " ".join(l[::-1]

Fixed submission:
input()
l = raw_input().split()
print " ".join(l[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
def LCS():
 x = raw_input()
 y = raw_input()
 i = len(x)
 j = len(y)

 dsp = [[0 for col in range(j+1)] for row in range(i+1)]
 for i in range(1,i+1):
  for j in range(1,j+1):
   if x[i-1] == y[j-1]:
    dsp[i][j] = dsp[i-1][j-1]+1
   else:
    dsp[i][j] = max(dsp[i-1][j],dsp[i][j-1])
 return dsp[i][j]

q = input()
for i in range(q):
 print LCS()

Fixed submission:
def LCS():
 x = raw_input()
 y = raw_input()
 a, b = len(x), len(y)
 dsp1 = [0 for i in xrange(b+1)]
 for i in xrange(a):
  dsp2 = dsp1+[]
  for j in xrange(b):
   if x[i] == y[j]:
    dsp1[j+1] = dsp2[j] + 1
   elif dsp1[j+1] < dsp1[j]:
    dsp1[j+1] = dsp1[j]
 print max(dsp1)
  
n = input()
for a in xrange(n):
    LCS()

Buggy python submission (verdict: Time Limit Exceeded):
def LCS():
 x = raw_input()
 y = raw_input()
 i, j = len(x), len(y)

 dsp = [[0 for col in xrange(j+1)] for row in xrange(i+1)]
 for i in xrange(1,i+1):
  for j in xrange(1,j+1):
   if x[i-1] == y[j-1]:
    dsp[i][j] = dsp[i-1][j-1]+1
   else:
    dsp[i][j] = max(dsp[i-1][j],dsp[i][j-1])
 print dsp[i][j]

q = input()
for i in range(q):
 LCS()

Fixed submission:
def LCS():
 x = raw_input()
 y = raw_input()
 a, b = len(x), len(y)
 dsp1 = [0 for i in xrange(b+1)]
 for i in xrange(a):
  dsp2 = dsp1+[]
  for j in xrange(b):
   if x[i] == y[j]:
    dsp1[j+1] = dsp2[j] + 1
   elif dsp1[j+1] < dsp1[j]:
    dsp1[j+1] = dsp1[j]
 print max(dsp1)
  
n = input()
for a in xrange(n):
    LCS()

Buggy python submission (verdict: Time Limit Exceeded):
def LCS():
 x = raw_input()
 y = raw_input()
 i, j = len(x), len(y)

 dsp = [[0 for col in xrange(j+1)] for row in xrange(i+1)]
 for i in xrange(1,i+1):
  for j in xrange(1,j+1):
   if x[i-1] == y[j-1]:
    dsp[i][j] = dsp[i-1][j-1]+1
   else:
    dsp[i][j] = max(dsp[i-1][j],dsp[i][j-1])
 print dsp[-1][-1]

q = input()
for i in xrange(q):
 LCS()

Fixed submission:
def LCS():
 x = raw_input()
 y = raw_input()
 a, b = len(x), len(y)
 dsp1 = [0 for i in xrange(b+1)]
 for i in xrange(a):
  dsp2 = dsp1+[]
  for j in xrange(b):
   if x[i] == y[j]:
    dsp1[j+1] = dsp2[j] + 1
   elif dsp1[j+1] < dsp1[j]:
    dsp1[j+1] = dsp1[j]
 print max(dsp1)
  
n = input()
for a in xrange(n):
    LCS()
Buggy python submission (verdict: Runtime Error):
n1 = input()
A = map(int, raw_input().split())

n2 = input()
q = map(int, raw_input().split())

list = set()

for i in range(n1):
 for j in range(n2):
  if i != j:
   list.add( A[i] + A[j] )

for i in range(n2):
  if q[i] in list:
   print "yes"
  else:
   print "no"

Fixed submission:
n1 = input()
A = map(int, raw_input().split())

n2 = input()
q = map(int, raw_input().split())

list = set()

def solve(i,m):
 if m == 0:
  return True
 if i >= n1 or m > sum(A):
  return False
 res = solve(i+1,m) or solve(i+1,m-A[i])
 return res

for m in q:
 if solve(0,m):
  print "yes"
 else:
  print "no"

Buggy python submission (verdict: Time Limit Exceeded):
n1 = input()
A = map(int, raw_input().split())

n2 = input()
q = map(int, raw_input().split())

list = set()

def solve(i,m):
 if m == 0:
  return True
 if i >= n1:
  return False
 res = solve(i+1,m) or solve(i+1,m-A[i])
 return res

for m in q:
 if solve(0,m):
  print "yes"
 else:
  print "no"

Fixed submission:
n1 = input()
A = map(int, raw_input().split())

n2 = input()
q = map(int, raw_input().split())

list = set()

def solve(i,m):
 if m == 0:
  return True
 if i >= n1 or m > sum(A):
  return False
 res = solve(i+1,m) or solve(i+1,m-A[i])
 return res

for m in q:
 if solve(0,m):
  print "yes"
 else:
  print "no"
Buggy python submission (verdict: Runtime Error):
input x

print x**3

Fixed submission:
x = input ()

print x**3
Buggy python submission (verdict: Runtime Error):
n = input()
for i in range(n):
 a = map(int,raw_input().split())

print min(a),max(a),sum(a)

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

print min(a),max(a),sum(a)
Buggy python submission (verdict: Runtime Error):
n = int( raw_input() )
   
d = [ 0 for i in range(n) ]
f = [ 0 for i in range(n) ]
G = [ 0 for i in range(n) ]
v = [ [0 for i in range(n) ] for j in range(n) ]
st = [ 0 for i in range(n) ]
tm = [ 0 ]
   
def DFS_visit(s):
  st[ s ] = 1
  tm[ 0 ] += 1
  d[ s ] = tm[ 0 ]
  for e in range(n):
    if v[ s ][ e ] == 1 and st[ e ] == 0:
      DFS_visit(e)
  st[ s ] == 2
  tm[ 0 ] += 1
  f[ s ] = tm[ 0 ]
   
def DFS():
  for s in range(n):
    if st[ s ] == 0:
      DFS_visit(s)
  for s in range(n):
     print'{ 0 } { 1 } { 2 }'.format( s+1 , d[ s ] , f[ s ] )
       
for i in range(n):
  G = map( int , raw_input().split() )
  for j in range( G[ 1 ] ):
    v[ G[ 0 ] - 1 ][G [ 2+j ] - 1 ] = 1
   
DFS()

Fixed submission:
n = int( raw_input() )
   
d = [ 0 for i in range(n) ]
f = [ 0 for i in range(n) ]
G = [ 0 for i in range(n) ]
v = [ [0 for i in range(n) ] for j in range(n) ]
st = [ 0 for i in range(n) ]
tm = [ 0 ]
   
def DFS_visit(s):
  st[ s ] = 1
  tm[ 0 ] += 1
  d[ s ] = tm[ 0 ]
  for e in range(n):
    if v[ s ][ e ] == 1 and st[ e ] == 0:
      DFS_visit(e)
  st[ s ] == 2
  tm[ 0 ] += 1
  f[ s ] = tm[ 0 ]
   
def DFS():
  for s in range(n):
    if st[ s ] == 0:
      DFS_visit(s)
  for s in range(n):
     print'{0} {1} {2}'.format( s+1 , d[ s ] , f[ s ] )
       
for i in range(n):
  G = map( int , raw_input().split() )
  for j in range( G[1] ):
    v[ G[0] -1 ][ G[ 2+j ] -1 ] = 1
   
DFS()

Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
   
d = [ 0 for i in range(n) ]
f = [ 0 for i in range(n) ]
G = [ 0 for i in range(n) ]
v = [ [0 for i in range(n) ] for j in range(n) ]
st = [ 0 for i in range(n) ]
tm = [ 0 ]
   
def DFS_visit(s):
  st[ s ] = 1
  tm[ 0 ] += 1
  d[ s ] = tm[ 0 ]
  for e in range(n):
    if v[ s ][ e ] == 1 and st[ e ] == 0:
      DFS_visit(e)
  st[ s ] == 2
  tm[ 0 ] += 1
  f[ s ] = tm[ 0 ]
   
def DFS():
  for s in range(n):
    if st[ s ] == 0:
      DFS_visit(s)
  for s in range(n):
     print'{ 0 } { 1 } { 2 }'.format( s+1 , d[ s ] , f[ s ] )
       
for i in range(n):
  G = map( int , raw_input().split() )
  for j in range( G[ 1 ] ):
    v[ G[ 0 ] - 1 ][G [ 2+j ] - 1 ] = 1
   
DFS()

Fixed submission:
n = int( raw_input() )
   
d = [ 0 for i in range(n) ]
f = [ 0 for i in range(n) ]
G = [ 0 for i in range(n) ]
v = [ [0 for i in range(n) ] for j in range(n) ]
st = [ 0 for i in range(n) ]
tm = [ 0 ]
   
def DFS_visit(s):
  st[ s ] = 1
  tm[ 0 ] += 1
  d[ s ] = tm[ 0 ]
  for e in range(n):
    if v[ s ][ e ] == 1 and st[ e ] == 0:
      DFS_visit(e)
  st[ s ] == 2
  tm[ 0 ] += 1
  f[ s ] = tm[ 0 ]
   
def DFS():
  for s in range(n):
    if st[ s ] == 0:
      DFS_visit(s)
  for s in range(n):
     print'{0} {1} {2}'.format( s+1 , d[ s ] , f[ s ] )
       
for i in range(n):
  G = map( int , raw_input().split() )
  for j in range( G[1] ):
    v[ G[0] -1 ][ G[ 2+j ] -1 ] = 1
   
DFS()