#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
const int mod = (1e9) + 7;
const long long inf = 1LL << 60;
map<int, int> Xs, Ys;
char s[MAXN];
long long xt[MAXN], yt[MAXN];
int n, h, w, sy, ret;
int dx, dy, mx, Mx, my, My;
long long go(int x, int dx, int mx, int Mx, int h, map<int, int> &Xs) {
  long long ret = inf;
  if (dx > 0) {
    if (x + Mx > h)
      ret = min(ret, (long long)Xs[h - x + 1]);
    else {
      int k = (h - Mx - x) / dx;
      while (x + k * dx + Mx <= h) ++k;
      int rx = h - x - k * dx + 1;
      ret = min(ret, Xs[rx] + (long long)k * n);
    }
  }
  if (dx < 0) {
    if (x + mx < 1)
      ret = min(ret, (long long)Xs[-x]);
    else {
      int k = (-x - mx) / dx;
      while (x + k * dx + mx > 0) ++k;
      int rx = -dx * k - x;
      ret = min(ret, Xs[rx] + (long long)k * n);
    }
  }
  if (x + Mx > h) ret = min(ret, (long long)Xs[h - x + 1]);
  if (x + mx < 1) ret = min(ret, (long long)Xs[-x]);
  return ret;
}
int main() {
  scanf("%d%d%d%s", &n, &h, &w, s);
  for (int i = 0; s[i]; ++i) {
    if (s[i] == 'U')
      --dx;
    else if (s[i] == 'D')
      ++dx;
    else if (s[i] == 'L')
      --dy;
    else if (s[i] == 'R')
      ++dy;
    if (!Xs.count(dx)) Xs[dx] = i + 1;
    if (!Ys.count(dy)) Ys[dy] = i + 1;
    mx = min(mx, dx);
    my = min(my, dy);
    Mx = max(Mx, dx);
    My = max(My, dy);
  }
  for (int x = 1; x <= h; ++x) xt[x - 1] = go(x, dx, mx, Mx, h, Xs);
  for (int y = 1; y <= w; ++y) yt[y - 1] = go(y, dy, my, My, w, Ys);
  sort(xt, xt + h);
  sort(yt, yt + w);
  if (xt[h - 1] == inf && yt[w - 1] == inf)
    ret = -1;
  else {
    for (int x = 0, y = 0; x < h; ++x) {
      while (y < w && yt[y] <= xt[x]) {
        sy += yt[y] % mod;
        sy %= mod;
        ++y;
      }
      xt[x] %= mod;
      ret += (sy + (long long)(w - y) * xt[x] % mod) % mod;
      ret %= mod;
    }
  }
  printf("%d", ret);
}
