// Cleaning Robot (F), by Errichto
// AC, O(w+h+n)
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
typedef long long ll;
const int nax = 5e5 + 5;
const int mod = 1e9 + 7;
char sl[nax];
int n;
int ans;
int low[2], high[2], curr[2], dimension[2];
bool f(ll moves, bool cheating) {
if(moves != 0 && moves % n == 0 && curr[0] == 0 && curr[1] == 0) {
puts("-1");
exit(0);
}
char type = sl[moves%n];
if(type == 'L') cheating ? curr[0] = high[0]+1 : ++curr[0];
else if(type == 'R') cheating ? curr[0] = low[0]-1 : --curr[0];
else if(type == 'U') cheating ? curr[1] = high[1]+1 : ++curr[1];
else if(type == 'D') cheating ? curr[1] = low[1]-1 : --curr[1];
else assert(false);
bool something_happened = false;
REP(i, 2) {
if(curr[i] < low[i] || curr[i] > high[i]) {
ans = (ans + (moves + 1) % mod * dimension[i^1]) % mod;
--dimension[i];
something_happened = true;
}
if(curr[i] < low[i]) low[i] = curr[i];
if(curr[i] > high[i]) high[i] = curr[i];
}
return something_happened;
}
bool inGame() { return dimension[0] > 0 && dimension[1] > 0; }
int main() {
scanf("%d%d%d", &n, &dimension[1], &dimension[0]);
scanf("%s", sl);
for(ll moves = 0; inGame() && moves < n; ++moves)
f(moves, false);
vector<int> w;
for(ll moves = n; inGame() && moves < 2 * n; ++moves)
if(f(moves, false)) w.push_back((int) moves % n);
for(ll k = 2; inGame(); ++k)
for(int moves : w) if(inGame())
f(k*n + moves, true);
printf("%d\n", ans);
return 0;
}
Ly8gQ2xlYW5pbmcgUm9ib3QgKEYpLCBieSBFcnJpY2h0bwovLyBBQywgTyh3K2grbikKI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBGT1IoaSxhLGIpIGZvcihpbnQgaSA9IChhKTsgaSA8PSAoYik7ICsraSkKI2RlZmluZ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