implementation

#include <algorithm>
#include <cstdio>
#include <numeric>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using namespace std;

int main() {
while (true) {
// input
int n, l; scanf("%d%d", &n, &l);
if (n == 0 and l == 0) break;
vector<char> d(n);
vector<int> p(n);
repeat (i, n) {
scanf(" %c%d", &d[i], &p[i]);
}
// solve
vector<int> t(n);
repeat (i, n) {
t[i] = (d[i] == 'L' ? p[i] : l - p[i]);
}
auto cmp = [&](int i, int j) {
return make_pair(t[i], d[i] == 'L') < make_pair(t[j], d[j] == 'L');
};
vector<int> xs(n);
iota(whole(xs), 0);
bool last_parity = p[*max_element(whole(xs), cmp)] % 2;
xs.erase(remove_if(whole(xs), [&](int i) {
return p[i] % 2 != last_parity;
}), xs.end());
sort(whole(xs), cmp);
int last_j = 0;
repeat (i, xs.size() - 1) {
if (d[xs[i]] == 'L') {
++ last_j;
}
}
sort(whole(xs));
last_j = xs[last_j];
// output
int last_t = *max_element(whole(t));
printf("%d %d\n", last_t, last_j + 1);
}
return 0;
}