https://www.codechef.com/problems/PERCAPTA

```
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define lld long long int
lld a[200005],b[200005],n,m,x,y,vis[200005],chose[200005];
vector <lld> temp,v[200005];
void bfs(lld u)
{
queue <lld> q;
q.push(u);
vis[u]=1;
temp.push_back(u);
while(!q.empty())
{
int val=q.front();
q.pop();
for(int i=0;i<v[val].size();i++)
{
if(!vis[v[val][i]] && chose[v[val][i]])
{
q.push(v[val][i]);
vis[v[val][i]]=1;
temp.push_back(v[val][i]);
}
}
}
}
int main() {
// your code goes here
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lld t;
cin>>t;
while(t--)
{
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<=n;i++)
cin>>b[i];
memset(chose,0,sizeof(chose));
memset(vis,0,sizeof(vis));
lld n=a[1],d=b[1];
for(int i=2;i<=n;i++)
{
if(a[i]*d>b[i]*n)
{
n=a[i];
d=b[i];
}
}
for(int i=1;i<=n;i++)
{
if(a[i]*d==b[i]*n)
chose[i]=1;
}
while(m--)
{
cin>>x>>y;
v[x].push_back(y);
v[y].push_back(x);
}
vector <lld> ans;
for(int i=1;i<=n;i++)
{
if(chose[i]&&!vis[i])
{
temp.clear();
bfs(i);
if(temp.size()>ans.size())
ans=temp;
}
}
cout<<ans.size()<<"\n";
for(int i=0;i<ans.size();i++)
cout<<ans[i]<<" ";
cout<<"\n";
for(int i=0;i<=n;i++)
v[i].clear();
}
}
```

This is giving SIGSEV. Please tell me my mistake