#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int n, q;
string s;
char t[100000], d[100000];
int move(int pos) {
  for (int i = 0; i < q; i++) {
    if (s[pos] == t[i]) {
      if (d[i] == 'R')
        pos++;
      else
        pos--;
    }
    if (pos == n)
      return n;
    else if (pos == -1)
      return -1;
  }
  return 0;
}
int judge_r(int right, int left) {
  while (right - left > 1) {
    int mid = (right + left) / 2;
    if (move(mid) == n)
      right = mid;
    else
      left = mid;
  }
  return right;
}
int judge_l(int right, int left) {
  while (right - left > 1) {
    int mid = (right + left) / 2;
    if (move(mid) == -1)
      left = mid;
    else
      right = mid;
  }
  return left;
}
int main() {
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  int left = -1, right = n;
  int r = n - judge_r(right, left);
  int l = 1 + judge_l(right, left);
  int ans = n - r - l;
  cout << "r " << r << endl;
  cout << "l " << l << endl;
  cout << ans << endl;
}
