#include <bits/stdc++.h>
#include "highway.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
/* ST1: start by setting all edges to A, calculate the depth of the node, traverse the tree changing 1 edge at a time. O(max depth) queries
* ST2: same, but after finding the depth, binary search on the possible nodes. set half of their parent edges to B at a time, O(log n) queries
* ST3 (line): set all edges to A to find the distance. then binary search on the starting node by setting 1 edge to B and checking if the path passes through it.
* ST4 (general tree):
*
*
*
*
*
*
*/
vector<vector<pii>> adj;
vector<int> d;
vector<pii> par;
void dfs(int x, int p) {
for(pii edge: adj[x]) {
int i = edge.first, idx = edge.second;
if(i==p)continue;
par[i]={x, idx};
d[i]=d[x]+1;
dfs(i,x);
}
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
adj.resize(N);
d.resize(N);
par.resize(N);
int M = U.size();
vector<int> query; query.assign(M,0);
ll toll = ask(query);
ll dist = toll/A;
int lo=0,hi=N-2;
while(lo<hi) {
int mid=(lo+hi)/2;
//cout<<mid<<"\n";
vector<int> query; query.assign(M,0);
for(int i=0;i<=mid;i++)query[i]=1;
ll toll2 = ask(query);
if(toll2 == toll) {
lo=mid+1;
}
else {
hi=mid;
}
}
answer(lo,lo+dist);
}