// 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;
}