#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>
#include<map>
#include<cassert>

using namespace std;

#define ll long long
#define reps(i, a, b) for(int i = a; i < b; i++)
#define rreps(i, a, b) for(int i = a-1; i >= b; i--)
#define rep(i, n) reps(i, 0, n)
#define rrep(i, n) rreps(i, n, 0)
#define P pair<int, int>
#define vec vector<int>
#define mat vector<vector<int> >

const ll mod = 1000000007;
const int INF = 1001001001;

int n;
vec c;
mat g;
map<int, int> path;
vec ans;

void dfs(int node, int old){
    rep(i, g[node].size()){
        int nx = g[node][i];
        if(old == nx) continue;
        if(path.find(c[nx]) == path.end()) {
            path[c[nx]] = 1;
            ans.push_back(nx);
        }else path[c[nx]]++;
        dfs(nx, node);
        if(path[c[nx]] == 1) path.erase(c[nx]);
        else path[c[nx]]--;
    }
}

int main(){
    cin >> n;
    c = vec(n);
    rep(i, n) cin >> c[i];
    g = mat(n);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    path[c[0]] = 1;
    dfs(0, -1);
    sort(ans.begin(), ans.end());
    cout << 1 << endl;
    rep(i, ans.size()){
        cout << ans[i] + 1 << endl;
    }
}
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = ((res%mod) * (a%mod))%mod;
      a = ((a%mod) * (a%mod))%mod;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  freopen("OUt.txt","w",stdout);
  #endif
}

bool isValid(int i,int j,int n,int m){
  if(i<=0 || j<=0 || i==n+1 || j==m+1)
    return 0;
  return 1;
}
int dx[4]={0,0,-1,1};
int dy[4]={1,-1,0,0};
char v[1001][1001]={};
int vis[1001][1001]={};
int p[100001]={};
int ans=0,n,m,k;
void dfs(int x,int y,int i){
  
  vis[x][y]=i;
  for(int h=0;h<4;h++){
    int nx=x+dx[h];
    int ny=y+dy[h];
    if(isValid(nx,ny,n,m) && v[nx][ny]=='*')
      ans++;
    else if(isValid(nx,ny,n,m) && v[nx][ny]=='.' && !vis[nx][ny])  
        dfs(nx,ny,i);
  }
}

int main() 
{ 
    fast_io
    go();
  int n,x,sum=0,v,p,i;
  cin>>n>>x;
  x=x*100;
  for(i=0;i<n;i++)
  {
      cin>>v>>p;
      sum=sum+(v*p);
      if(sum>x)
      {
      cout<<i+1<<endl;
      break;
          
      }
      
  }
  if(i==n)
  {
      cout<<"-1";
  }
  return 0;
}
/*!
    You are under no obligation to be the same person you were a minute ago,
    You have the right to grow !
*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
