Buggy python submission (verdict: Runtime Error):
import collections
import math

n = int(input())
m = 0
mod = 10 ** 6 + 7
c = []
d = []
frac = {}
tmp = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        tmp += 1
        m += 1
        continue
    try:
        if a == 0:
            frac['0'] += 1
        elif b == 0:
            frac['inf'] += 1
        else:
            gcd = abs(math.gcd(a, b))
            sign = 1 if a * b > 0 else -1
            a = sign * abs(a) // gcd
            b = abs(b) // gcd
            frac['{}/{}'.format(a, b)] += 1
    except KeyError:
        if a == 0:
            frac['0'] = 1
        elif b == 0:
            frac['inf'] = 1
        else:
            gcd = abs(math.gcd(a, b))
            sign = a * b // abs(a * b)
            a = sign * abs(a) // gcd
            b = abs(b) // gcd
            frac['{}/{}'.format(a, b)] = 1

n -= tmp

def inverse(key):
    if key[0] != '-':
        a, b = key.split('/')
        return '-{}/{}'.format(b, a)
    else:
        a, b = key[1:].split('/')
        return '{}/{}'.format(b, a)

for key, value in frac.items():
    if key == '0': continue
    if key[0] == '-': continue
    try:
        if key == float('inf'):
            d.append(frac['inf'])
        else:
            d.append(frac[inverse(key)])
        c.append(value)
    except KeyError:
        continue

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1)
    ans = (ans * (pow(2, i, mod) + pow(2, j, mod) - 1)) % mod
ans = (ans * (m + 1) - 1) % mod

print(ans)

Fixed submission:
import collections
import math

n = int(input())
m = 0
mod = 10 ** 9 + 7
c = []
d = []
frac = []

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        n -= 1
        m += 1
        continue
    if a == 0:
        frac.append('0/1')
    elif b == 0:
        frac.append(('1/0'))
    else:
        gcd = abs(math.gcd(a, b))
        sign = 1 if a * b > 0 else -1
        a = sign * abs(a) // gcd
        b = abs(b) // gcd
        frac.append('{}/{}'.format(a, b))

frac = collections.Counter(frac)

def inverse(key):
    if key == '0/1':
        return '1/0'
    elif key == '1/0':
        return '0/1'
    elif key[0] != '-':
        a, b = key.split('/')
        return '-{}/{}'.format(b, a)
    else:
        a, b = key[1:].split('/')
        return '{}/{}'.format(b, a)

for key, value in frac.items():
    if key[0] == '-' or key[0] == '0': continue
    if frac[inverse(key)] > 0:
        c.append(value)
        d.append(frac[inverse(key)])

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1) % mod
    ans = ans * tmp % mod
ans = (ans - 1 + m) % mod

print(ans)

Buggy python submission (verdict: Runtime Error):
import collections
import math

n = int(input())
m = 0
mod = 10 ** 6 + 7
c = []
d = []
frac = {}
tmp = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        tmp += 1
        m += 1
        continue
    try:
        if a == 0:
            frac['0'] += 1
        elif b == 0:
            frac['inf'] += 1
        else:
            gcd = abs(math.gcd(a, b))
            sign = a * b // abs(a * b)
            a = sign * abs(a) // gcd
            b = abs(b) // gcd
            frac['{}/{}'.format(a, b)] += 1
    except KeyError:
        if a == 0:
            frac['0'] = 1
        elif b == 0:
            frac['inf'] = 1
        else:
            gcd = abs(math.gcd(a, b))
            sign = a * b // abs(a * b)
            a = sign * abs(a) // gcd
            b = abs(b) // gcd
            frac['{}/{}'.format(a, b)] = 1

n -= tmp

def inverse(key):
    if key[0] != '-':
        a, b = key.split('/')
        return '-{}/{}'.format(b, a)
    else:
        a, b = key[1:].split('/')
        return '{}/{}'.format(b, a)

for key, value in frac.items():
    if key == '0': continue
    if key != 'inf' and key[0] == '-': continue
    try:
        if key == float('inf'):
            d.append(frac['inf'])
        else:
            d.append(frac[inverse(key)])
        c.append(value)
    except KeyError:
        continue

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1)
    ans = (ans * (pow(2, i, mod) + pow(2, j, mod) - 1)) % mod
ans = ans * (m + 1) - 1

print(ans)

Fixed submission:
import collections
import math

n = int(input())
m = 0
mod = 10 ** 9 + 7
c = []
d = []
frac = []

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        n -= 1
        m += 1
        continue
    if a == 0:
        frac.append('0/1')
    elif b == 0:
        frac.append(('1/0'))
    else:
        gcd = abs(math.gcd(a, b))
        sign = 1 if a * b > 0 else -1
        a = sign * abs(a) // gcd
        b = abs(b) // gcd
        frac.append('{}/{}'.format(a, b))

frac = collections.Counter(frac)

def inverse(key):
    if key == '0/1':
        return '1/0'
    elif key == '1/0':
        return '0/1'
    elif key[0] != '-':
        a, b = key.split('/')
        return '-{}/{}'.format(b, a)
    else:
        a, b = key[1:].split('/')
        return '{}/{}'.format(b, a)

for key, value in frac.items():
    if key[0] == '-' or key[0] == '0': continue
    if frac[inverse(key)] > 0:
        c.append(value)
        d.append(frac[inverse(key)])

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1) % mod
    ans = ans * tmp % mod
ans = (ans - 1 + m) % mod

print(ans)

Buggy python submission (verdict: Runtime Error):
import collections
import fractions

n = int(input())
m = 0
mod = 10 ** 6 + 7
c = []
d = []
frac = {}
tmp = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        tmp += 1
        m += 1
        continue
    try:
        if b == 0: frac[float('inf')] += 1
        else: frac[fractions.Fraction(a, b)] += 1
    except KeyError:
        if b == 0: frac[float('inf')] = 1
        else: frac[fractions.Fraction(a, b)] = 1
n -= tmp

for key, value in frac.items():
    if key > 0: continue
    try:
        if key == float('inf'):
            d.append(frac[fractions.Fraction(0)])
        else:
            d.append(frac[-1 / key])
        c.append(value)
    except KeyError:
        continue

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1)
    ans = (ans * (pow(2, i, mod) + pow(2, j, mod) - 1)) % mod
ans -= 1 + m

print(ans)

Fixed submission:
import collections
import math

n = int(input())
m = 0
mod = 10 ** 9 + 7
c = []
d = []
frac = []

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        n -= 1
        m += 1
        continue
    if a == 0:
        frac.append('0/1')
    elif b == 0:
        frac.append(('1/0'))
    else:
        gcd = abs(math.gcd(a, b))
        sign = 1 if a * b > 0 else -1
        a = sign * abs(a) // gcd
        b = abs(b) // gcd
        frac.append('{}/{}'.format(a, b))

frac = collections.Counter(frac)

def inverse(key):
    if key == '0/1':
        return '1/0'
    elif key == '1/0':
        return '0/1'
    elif key[0] != '-':
        a, b = key.split('/')
        return '-{}/{}'.format(b, a)
    else:
        a, b = key[1:].split('/')
        return '{}/{}'.format(b, a)

for key, value in frac.items():
    if key[0] == '-' or key[0] == '0': continue
    if frac[inverse(key)] > 0:
        c.append(value)
        d.append(frac[inverse(key)])

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1) % mod
    ans = ans * tmp % mod
ans = (ans - 1 + m) % mod

print(ans)

Buggy python submission (verdict: Runtime Error):
import collections
import fractions

n = int(input())
m = 0
mod = 10 ** 6 + 7
c = []
d = []
frac = {}
tmp = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        tmp += 1
        m += 1
    try:
        if b == 0: frac[float('inf')] += 1
        else: frac[fractions.Fraction(a, b)] += 1
    except KeyError:
        if b == 0: frac[float('inf')] = 1
        else: frac[fractions.Fraction(a, b)] = 1
n -= tmp

for key, value in frac.items():
    if key > 0: continue
    try:
        if key == float('inf'):
            d.append(frac[fractions.Fraction(0)])
        else:
            d.append(frac[-1 / key])
        c.append(value)
    except KeyError:
        continue

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1)
    ans = (ans * (pow(2, i, mod) + pow(2, j, mod) - 1)) % mod
ans -= 1 + m

print(ans)

Fixed submission:
import collections
import math

n = int(input())
m = 0
mod = 10 ** 9 + 7
c = []
d = []
frac = []

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        n -= 1
        m += 1
        continue
    if a == 0:
        frac.append('0/1')
    elif b == 0:
        frac.append(('1/0'))
    else:
        gcd = abs(math.gcd(a, b))
        sign = 1 if a * b > 0 else -1
        a = sign * abs(a) // gcd
        b = abs(b) // gcd
        frac.append('{}/{}'.format(a, b))

frac = collections.Counter(frac)

def inverse(key):
    if key == '0/1':
        return '1/0'
    elif key == '1/0':
        return '0/1'
    elif key[0] != '-':
        a, b = key.split('/')
        return '-{}/{}'.format(b, a)
    else:
        a, b = key[1:].split('/')
        return '{}/{}'.format(b, a)

for key, value in frac.items():
    if key[0] == '-' or key[0] == '0': continue
    if frac[inverse(key)] > 0:
        c.append(value)
        d.append(frac[inverse(key)])

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1) % mod
    ans = ans * tmp % mod
ans = (ans - 1 + m) % mod

print(ans)

Buggy python submission (verdict: Runtime Error):
import collections
import fractions

n = int(input())
m = 0
mod = 10 ** 6 + 7
c = []
d = []
frac = {}

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        n -= 1
        m += 1
    try:
        if b == 0: frac[float('inf')] += 1
        else: frac[fractions.Fraction(a, b)] += 1
    except KeyError:
        if b == 0: frac[float('inf')] = 1
        else: frac[fractions.Fraction(a, b)] = 1

for key, value in frac.items():
    if key > 0: continue
    try:
        if key == float('inf'):
            d.append(frac[fractions.Fraction(0)])
        else:
            d.append(frac[-1 / key])
        c.append(value)
    except KeyError:
        continue

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1)
    ans = (ans * (pow(2, i, mod) + pow(2, j, mod) - 1)) % mod
ans -= 1 + m

print(ans)

Fixed submission:
import collections
import math

n = int(input())
m = 0
mod = 10 ** 9 + 7
c = []
d = []
frac = []

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        n -= 1
        m += 1
        continue
    if a == 0:
        frac.append('0/1')
    elif b == 0:
        frac.append(('1/0'))
    else:
        gcd = abs(math.gcd(a, b))
        sign = 1 if a * b > 0 else -1
        a = sign * abs(a) // gcd
        b = abs(b) // gcd
        frac.append('{}/{}'.format(a, b))

frac = collections.Counter(frac)

def inverse(key):
    if key == '0/1':
        return '1/0'
    elif key == '1/0':
        return '0/1'
    elif key[0] != '-':
        a, b = key.split('/')
        return '-{}/{}'.format(b, a)
    else:
        a, b = key[1:].split('/')
        return '{}/{}'.format(b, a)

for key, value in frac.items():
    if key[0] == '-' or key[0] == '0': continue
    if frac[inverse(key)] > 0:
        c.append(value)
        d.append(frac[inverse(key)])

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1) % mod
    ans = ans * tmp % mod
ans = (ans - 1 + m) % mod

print(ans)

Buggy python submission (verdict: Runtime Error):
import collections
import fractions

n = int(input())
mod = 10 ** 6 + 7
c = []
d = []

frac = {}

for _ in range(n):
    a, b = map(int, input().split())
    try:
        if b == 0: frac[float('inf')] += 1
        else: frac[fractions.Fraction(a, b)] += 1
    except KeyError:
        if b == 0: frac[float('inf')] = 1
        else: frac[fractions.Fraction(a, b)] = 1

for key, value in frac.items():
    if -1 <= key < 1: continue
    try:
        if key == 0:
            d.append(frac[float('inf')])
        elif key == float('inf'):
            d.append(fractions.Fraction())
        else:
            d.append(frac[-1 / key])
        c.append(value)
    except KeyError:
        continue

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1)
    ans = (ans * (pow(2, i, mod) + pow(2, j, mod) - 1)) % mod
ans -= 1

print(ans)

Fixed submission:
import collections
import math

n = int(input())
m = 0
mod = 10 ** 9 + 7
c = []
d = []
frac = []

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        n -= 1
        m += 1
        continue
    if a == 0:
        frac.append('0/1')
    elif b == 0:
        frac.append(('1/0'))
    else:
        gcd = abs(math.gcd(a, b))
        sign = 1 if a * b > 0 else -1
        a = sign * abs(a) // gcd
        b = abs(b) // gcd
        frac.append('{}/{}'.format(a, b))

frac = collections.Counter(frac)

def inverse(key):
    if key == '0/1':
        return '1/0'
    elif key == '1/0':
        return '0/1'
    elif key[0] != '-':
        a, b = key.split('/')
        return '-{}/{}'.format(b, a)
    else:
        a, b = key[1:].split('/')
        return '{}/{}'.format(b, a)

for key, value in frac.items():
    if key[0] == '-' or key[0] == '0': continue
    if frac[inverse(key)] > 0:
        c.append(value)
        d.append(frac[inverse(key)])

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1) % mod
    ans = ans * tmp % mod
ans = (ans - 1 + m) % mod

print(ans)

Buggy python submission (verdict: Runtime Error):
import collections
import fractions

n = int(input())
mod = 10 ** 6 + 7
c = []
d = []

tan = []
atan = []

for _ in range(n):
    a, b = map(int, input().split())
    if b == 0: tan.append(float('inf'))
    else: tan.append(fractions.Fraction(a, b))
    if a == 0: atan.append(float('inf'))
    else: atan.append(fractions.Fraction(-1 * b, a))

tan = collections.Counter(tan)
atan = collections.Counter(atan)

for key, value in tan.items():
    if -1 <= key < 1: continue
    if atan[key] > 0:
        c.append(value)
        d.append(atan[key])

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1)
    ans = (ans * (pow(2, i, mod) + pow(2, j, mod) - 1)) % mod
ans -= 1

print(ans)

Fixed submission:
import collections
import math

n = int(input())
m = 0
mod = 10 ** 9 + 7
c = []
d = []
frac = []

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        n -= 1
        m += 1
        continue
    if a == 0:
        frac.append('0/1')
    elif b == 0:
        frac.append(('1/0'))
    else:
        gcd = abs(math.gcd(a, b))
        sign = 1 if a * b > 0 else -1
        a = sign * abs(a) // gcd
        b = abs(b) // gcd
        frac.append('{}/{}'.format(a, b))

frac = collections.Counter(frac)

def inverse(key):
    if key == '0/1':
        return '1/0'
    elif key == '1/0':
        return '0/1'
    elif key[0] != '-':
        a, b = key.split('/')
        return '-{}/{}'.format(b, a)
    else:
        a, b = key[1:].split('/')
        return '{}/{}'.format(b, a)

for key, value in frac.items():
    if key[0] == '-' or key[0] == '0': continue
    if frac[inverse(key)] > 0:
        c.append(value)
        d.append(frac[inverse(key)])

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1) % mod
    ans = ans * tmp % mod
ans = (ans - 1 + m) % mod

print(ans)