my $N = <>;chomp $N;
my $mod = 1000000007;
my %DB;
my %MDB;
my $sum=1;
my $zero=0;
for(my $i=0;$i<$N;$i++){
    my @dat = split(/ /,<>);
    if(($dat[0]*$dat[1])==0){
        $zero++;
        next;
    }
    my $g = gcd($dat[0],$dat[1]);
    my $v = ($dat[0]/$g)/($dat[1]/$g);
    #print "$v\n";
    if($v>0){
      $DB{$v}++;
    }elsif($v<0){
      $v = -1/$v;
      $MDB{$v}++;  
    }
}
foreach my $key (sort {$a<=> $b} keys %MDB){
    #print "$key\n";
    if(defined($DB{$key})){
       #print "$N = $N - $DB{$key} - $MDB{$key}\n";
       #$sum = ($sum *  (2**$DB{$key} + 2** $MDB{$key} -1) )%$mod;
       $sum = ($sum *  (powmod(2,$DB{$key},$mod) + powmod(2,$MDB{$key},$mod) -1) )%$mod;
       $N = $N - $DB{$key} - $MDB{$key};
    }
}
#print "N$N\n";
$N = $N -$zero;
$sum = ($sum * ($zero +1))%$mod;
$sum= (((2**$N) * $sum )-1)%$mod;
print "$sum";

sub powmod{
   my ($a,$b,$m) = @_;
   if($b==0){return 1;}
   my $c = powmod(($a*$a)%$m,int($b/2),$m);
   if($b%2){
     $c = ($c*$a)%$m;
   }
   return $c;
}
sub gcd{ #最大公約数
    my ($a,$b) = @_;
    if($b == 0){
        return $a;
    }
 
    return gcd($b, $a%$b);
}