#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

// N, E, S, W
const int dx[4] = {-1, 0,  1,  0};
const int dy[4] = { 0, 1,  0, -1};

map<char, int> mpdir = {
    {'U', 0}, {'R', 1}, {'D', 2}, {'L', 3}
};

int W, H, N;
int e[501][501][2]; // e[x][y][d] (d = 0: down, d = 1: right)

inline bool inside(int x, int y, int R, int C) {
    return 0 <= x && x < R && 0 <= y && y < C;
}

void add(int x, int y, int k) {
    if (k == 1 || k == 2) {
        x += dx[k], y += dy[k];
    }
    ++e[x][y][(k % 2) ^ 1];
    // cout << x << " " << y << " " << k % 2 << endl;
}

void move(int& x, int& y, int k) {
    // people can move in 0 <= x < H, 0 <= y < W
    if (inside(x + dx[k], y + dy[k], H, W)) {
        add(x, y, k);
        x += dx[k], y += dy[k];
    }
}

void update() {
    int x, y;
    cin >> y >> x;
    int T;
    cin >> T;
    string s;
    cin >> s;
    rep(t, T) {
        rep(i, s.size()) {
            // cout << x << " " << y << endl;
            move(x, y, mpdir[s[i]]);
        }
    }
}

int getCost(int x, int y, int k) {
    if (k == 0 || k == 3) {
        x += dx[k], y += dy[k];
    }
    // cout << "getCost " << x << " " << y << " " << k << ": " << e[x][y][k % 2] << endl;
    return e[x][y][k % 2];
}

int dijkstra(int sx, int sy, int gx, int gy) {
    priority_queue<TUPLE, vector<TUPLE>, greater<TUPLE>> pq;   // cost, x, y
    VV d(H + 1, V(W + 1, inf));
    d[sx][sy] = 0;
    pq.push(TUPLE(0, sx, sy));

    while (!pq.empty()) {
        int c, x, y;
        tie(c, x, y) = pq.top(); pq.pop();

        // cout << c << " " << x << " " << y << endl;

        if (x == gx && y == gy) break;
        if (d[x][y] < c) continue;

        rep(k, 4) {
            int nx = x + dx[k], ny = y + dy[k];
            // !!! cable can move in 0 <= x < H + 1, 0 <= y < W + 1 !!!
            if (!inside(nx, ny, H + 1, W + 1)) continue;
            int nc = c + getCost(x, y, k);
            if (d[nx][ny] > nc) {
                d[nx][ny] = nc;
                pq.push(TUPLE(nc, nx, ny));
            }
        }
    }
    return d[gx][gy];
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    cin >> W >> H >> N;
    int cable_sx, cable_sy, cable_gx, cable_gy;
    cin >> cable_sy >> cable_sx >> cable_gy >> cable_gx;
    rep(i, N) {
        update();

        // rep(i, H + 1) {
        //     rep(j, W + 1) {
        //         cout << "(" << e[i][j][0] << ", " << e[i][j][1] << ")" << " ";
        //     }
        //     cout << endl;
        // }
        // cout << endl;

        // rep(i, H + 1) {
        //     rep(j, W + 1) {
        //         cout << "(" << getCost(i, j, 2) << ", " << getCost(i, j, 1) << ")" << " ";
        //     }
        //     cout << endl;
        // }
    }

    cout << dijkstra(cable_sx, cable_sy, cable_gx, cable_gy) << endl;

}