#include <bits/stdc++.h>
#define int long long
inline int read() {
int x = 0; bool f = true; char ch = getchar();
for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = false;
for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
return f ? x : (~(x - 1));
}
inline char rech() {
char ch = getchar();
for (; !isgraph(ch); ch = getchar());
return ch;
}
const int M = (int)1e5 + 5;
char a[M], b[M];
int la[M], lb[M];
struct node {
int dx, dy, len;
};
std :: vector <node> op;
signed main() {
int x1 = read(), y1 = read(), x2 = read(), y2 = read();
int n = read(), m = read(), l = read();
for (int i = 1; i <= m; ++i) {
a[i] = rech();
la[i] = read() + la[i - 1];
}
for (int i = 1; i <= l; ++i) {
b[i] = rech();
lb[i] = read() + lb[i - 1];
}
for (int i = 1, j = 1, T = 0; T < n; ) {
int len = std :: min(la[i] - T, lb[j] - T);
int dx = 0, dy = 0;
if (b[j] == 'R') ++dy;
if (b[j] == 'L') --dy;
if (a[i] == 'R') --dy;
if (a[i] == 'L') ++dy;
if (b[j] == 'U') --dx;
if (b[j] == 'D') ++dx;
if (a[i] == 'U') ++dx;
if (a[i] == 'D') --dx;
T += len; op.push_back((node){dx, dy, len});
if (T == la[i]) ++i;
if (T == lb[j]) ++j;
}
int x = x2 - x1, y = y2 - y1;
int ans = 0;
for (node o : op) {
// std :: cout << x << ' ' << y << ' ' << o.dx << ' ' << o.dy << ' ' << o.len << std :: endl;
int nx = x + o.dx * o.len, ny = y + o.dy * o.len;
if (o.dx == 0 && o.dy == 0 && x == 0 && y == 0) {
ans += o.len;
} else if (x != 0 || y != 0) {
if (std :: abs(o.dx) == 2 && o.dy == 0) {
if (x * nx <= 0 && y == 0 && std :: abs(x) % 2 == 0) ++ans;
} else if (std :: abs(o.dy) == 2 && o.dx == 0) {
if (y * ny <= 0 && x == 0 && std :: abs(y) % 2 == 0) ++ans;
} else if (std :: abs(x) == std :: abs(y)) {
if (x * nx <= 0 && y * ny <= 0) ++ans;
}
}
x = nx; y = ny;
}
printf("%lld\n", ans);
return 0;
}
八点四十的时候开始 WA 一个点,到九点四十一直调这个题也没调出来,我真不想说啥了