#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define mp make_pair
#define ll long long
int main() {
int k;
scanf("%d", &k);
string s;
cin >> s;
set<pair<ll, ll>> used;
map<pair<pair<ll, ll>, char>, pair<ll, ll>> go; //from, dir -> to
long long x = 0, y = 0;
used.insert(mp(x, y));
for (int i = 0; i < k; i ++) {
int dy = 0, dx = 0;
if (s[i] == 'L') dx --;
if (s[i] == 'R') dx ++;
if (s[i] == 'D') dy --;
if (s[i] == 'U') dy ++;
long long fromx = x, fromy = y;
for (;;) {
if (!used.count(mp(x, y))) break;
if (go.count(mp(mp(x, y), s[i]))) {
int nx = go[mp(mp(x, y), s[i])].first;
int ny = go[mp(mp(x, y), s[i])].second;
x = nx, y = ny;
}
x += dx, y += dy;
}
used.insert(mp(x, y));
go[mp(mp(fromx, fromy), s[i])] = mp(x, y);
}
printf("%lld %lld\n", x, y);
return 0;
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:15:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &k);
^