Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
l = [tuple(input().split()) for _ in range(m)]
subs = [[] for _ in range(n)]

for i in range(m):
    subs[int(l[i][0])-1].append(l[i][1])

ac, p = 0, 0

for j in range(n):
    for k in range(len(subs[j])):
        if subs[j][k] == 'AC':
            ac += 1
        
        if 'AC' in subs[j]:
            if subs[j][k] == 'WA':
                p += 1
            else:
                break

print(ac, p)

Fixed submission:
n, m = map(int, input().split())
l = [tuple(input().split()) for _ in range(m)]
subs = [[] for _ in range(n)]

for i in range(m):
    subs[int(l[i][0])-1].append(l[i][1])

ac, p = 0, 0

for j in range(n):
    if 'AC' in subs[j]:
        ac += 1
        for k in range(len(subs[j])):
                if subs[j][k] == 'WA':
                    p += 1
                else:
                    break

print(ac, p)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
l = [tuple(input().split()) for _ in range(m)]
subs = [[] for _ in range(n)]

for i in range(m):
    subs[int(l[i][0])-1].append(l[i][1])

ac, p = 0, 0

for j in range(n):
    for k in range(len(subs[j])):
        if subs[j][k] == 'AC':
            ac += 1
        
        if 'AC' in subs[j]:
            if subs[j][k] == 'WA':
                p += 1
            else:
                break

print(ac, p)

Fixed submission:
n, m = map(int, input().split())
l = [tuple(input().split()) for _ in range(m)]
subs = [[] for _ in range(n)]

for i in range(m):
    subs[int(l[i][0])-1].append(l[i][1])

ac, p = 0, 0

for j in range(n):
    if 'AC' in subs[j]:
        ac += 1
        for k in range(len(subs[j])):
                if subs[j][k] == 'WA':
                    p += 1
                else:
                    break

print(ac, p)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
l = [list(input().split()) for _ in range(m)]
subs = [[] for _ in range(n)]

for i in range(m):
    subs[int(l[i][0])-1].append(l[i][1])

ac, p = 0, 0
for j in range(n):
    for k in range(len(subs[j])):
        if subs[j][k] == 'AC':
            ac += 1
        
        if 'AC' in subs[j]:
            if subs[j][k] == 'WA':
                p += 1
            else:
                break

print(ac, p)

Fixed submission:
n, m = map(int, input().split())
l = [tuple(input().split()) for _ in range(m)]
subs = [[] for _ in range(n)]

for i in range(m):
    subs[int(l[i][0])-1].append(l[i][1])

ac, p = 0, 0

for j in range(n):
    if 'AC' in subs[j]:
        ac += 1
        for k in range(len(subs[j])):
                if subs[j][k] == 'WA':
                    p += 1
                else:
                    break

print(ac, p)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
l = [input().split(" ") for _ in range(m)]
#print(l)

temp=0
wa=0
ac=0
for i in range(n):
    for j in range(m):
        if l[j][0] == str(i+1):
            #print(l[j][0], str(i+1))
            if l[j][1]=='WA':
                temp+=1
            else:
                ac+=1
                wa+=temp
                temp=0
                break

    
print(ac,wa)

Fixed submission:
n, m = map(int, input().split())
l = [tuple(input().split()) for _ in range(m)]
subs = [[] for _ in range(n)]

for i in range(m):
    subs[int(l[i][0])-1].append(l[i][1])

ac, p = 0, 0

for j in range(n):
    if 'AC' in subs[j]:
        ac += 1
        for k in range(len(subs[j])):
                if subs[j][k] == 'WA':
                    p += 1
                else:
                    break

print(ac, p)