#include<bits/stdc++.h>
using namespace std;
//main sample
//by six_sigma
#define fastio ios::sync_with_stdio(false);cin.tie(0); 
#define ll long long int
//defining loops
#define lp0(i,a) for(i=0;i<a;i++)
#define lp1(i,a) for(i=1;i<=a;i++)
//defining file input output(T.N.T.I)
#define f_input freopen("input.txt","r",stdin)
#define f_output freopen("output.txt","w",stdout)
//defining stl operations
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define si stack<int>
#define qi queue<int>
//defining input output
#define sf scanf
#define pf printf
#define endl "\n"

void solve(){
    ll a,i;
    double b;
    cin>>a>>b;
   
    double sum=0;
    double x,y;
    bool flag=false;
    lp0(i,a){
        cin>>x>>y;
        x*=(y/100);
        
        sum+=x;
        if(sum-b>(1e-6)){
            cout<<i+1<<endl;
            flag=true;
            break;
        }
    }
    if(!flag)cout<<-1<<endl;
}

int main(){
    fastio
    int t=1;
    
    while(t--)solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define Rep(i,j,n) for(int i=j; i<n; i++)
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//0000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
//#define P pair<ll, ll>
//#define P pair<double, double>
#define PP pair<P,P>
#define T tuple<int,int,int>



struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};


int main(){
  int n,m; cin >> n >> m;
  vector<int> a(n),b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  UnionFind u(n);
  rep(i,m){
    int c,d; cin >> c >> d;
    c--; d--;
    u.unite(c,d);
  }
  vector<vector<int> > g(n);
  rep(i,n){
    int w=u.find(i);
    g[w].push_back(i);
  }
  rep(i,g.size()){
    ll v,v2;
    v=v2=0;
    for(auto x : g[i]){
      v+=a[x]; v2+=b[x];
    }
    if(v!=v2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

