import kotlin.math.abs
import kotlin.math.pow

val M = 1000000007L

fun main() {
    val n = readLine()!!.toInt()
    var zeros = 0L
    val iwashiMap = mutableMapOf<Fraction, Long>()
    repeat(n) {
        val (a, b) = readLine()!!.split(" ")
        val aa = a.toLong()
        val bb = b.toLong()
        val f = fraction(aa, bb)
        if (f is Fraction.Zero) {
            zeros += 1
        } else {
            val v = iwashiMap.getOrDefault(f, 0)
            iwashiMap[f] = v + 1
        }
    }

    iwashiMap.keys.forEach { f ->
        val o = f.opposite()
        if (iwashiMap.containsKey(o)) f.hasOpposite = o
    }

    val resultMap = mutableMapOf<Set<Fraction>, Long>()

    iwashiMap.forEach { (k, v) -> resultMap[setOf(k)] = pow2(v) }
    iwashiMap.forEach { (f, n) ->
        val pn = pow2(n)
        val tempMap = mutableMapOf<Set<Fraction>, Long>()
        resultMap.forEach inner@{ fs, m ->
            if (fs.mapNotNullTo(mutableSetOf()) { it.hasOpposite }.contains(f)) return@inner
            tempMap[fs + f] = m * pn % M
        }
        resultMap += tempMap
        resultMap[setOf(f)] = pn
    }
    val index = resultMap.values.fold(0L) { b, a -> (a + b) % M }
    val result = (zeros + index) % M
    println(result)
}

fun pow2(n: Long): Long = 2.0.pow(n.toDouble()).toLong()

sealed class Fraction {
    data class F(val m: Long, val n: Long) : Fraction() {
        override fun opposite(): Fraction = if (m > 0) F(-n, m) else F(n, -m)
    }

    object ZeroOne : Fraction() {
        override fun opposite(): Fraction = OneZero
    }

    object OneZero : Fraction() {
        override fun opposite(): Fraction = ZeroOne
    }

    object Zero : Fraction() {
        override fun opposite(): Fraction = Zero
    }

    abstract fun opposite(): Fraction
    var hasOpposite: Fraction? = null
}

fun fraction(m: Long, n: Long): Fraction {
    return when {
        m == 0L && n == 0L -> Fraction.Zero
        m == 0L -> Fraction.ZeroOne
        n == 0L -> Fraction.OneZero
        else -> {
            val a = gcd(m, n)
            if (n < 0) Fraction.F(-m / a, -n / a) else Fraction.F(m / a, n / a)
        }
    }
}

fun gcd(a: Long, b: Long): Long {
    tailrec fun go(c: Long, d: Long): Long = if (d == 0L) c else go(d, c % d)

    val m = abs(a)
    val n = abs(b)
    return if (m > n) go(m, n) else go(n, m)
}
