#include #include #include using namespace std; int N,X,Y; int x[4<<17],y[4<<17]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>X>>Y; for(int i=0;i>p>>c; if(c=='A')x[i%(X+Y)]+=p; else y[i%(X+Y)]+=p; } long ans=0; for(int i=0;i