#include "multi.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
const unsigned int one = 1;
vector<unsigned long long> strategy(int32_t N,
int32_t r,int32_t i,
vector<unsigned long long> A,
vector<unsigned long long> B){
unsigned int gameState = B[0];
if(gameState==0){
gameState = 1;
} else {
pair<unsigned int,int> ans = {(one<<50),0ll};
for(int x=1;x<N;x++){
if(gameState&(one<<x))continue;
ans = min(ans,{B[x],x});
}
gameState|=(one<<ans.second);
}
// assert(r==__builtin_popcount(gameState)-1);
auto staticReturner = [&](int x){
return vector<unsigned long long>(N,x);
};
if(i==0){
// orchastrator
unsigned long long full = (N == 64) ? ~0ULL : (1ULL << N) - 1;
if(gameState==full){
int ans = 0;
for(int x=1;x<N;x++)ans+=B[x];
return {(unsigned int)ans};
}
return staticReturner(gameState);
} else {
if(gameState&(one<<i))return staticReturner(B[i]);
unsigned int myMin = (one<<50);
for(int x=0;x<N;x++)if(gameState&(one<<x)){
myMin = min(myMin,A[x]);
}
return staticReturner(myMin);
}
}