extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::fmt::{Display, Error, Formatter};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet};

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
fn main() {
    loop {
        let_all!(n: usize, l: usize);
        if n == 0 {
            return
        }
        let mut to_left_position = Vec::new();
        let mut to_left_id = Vec::new();
        let mut to_right_position = Vec::new();
        let mut to_right_id = Vec::new();
        for i in 0 .. n {
            let_all!(d: String, p: usize);
            match &d[..] {
                "R" => {
                    to_right_position.push(p);
                    to_right_id.push(i + 1);
                },
                "L" => {
                    to_left_position.push(p);
                    to_left_id.push(i + 1);
                },
                _ => unreachable!()
            }
        }
        for j in 0 .. to_left_id.len() {
            for ri in 0 .. to_right_id.len() {
                let i = to_right_id.len() - ri - 1;
                if to_right_position[i] < to_left_position[j] && (to_left_position[j] - to_right_position[i]) % 2 == 0 {
                    let temp = to_right_id[i];
                    to_right_id[i] = to_left_id[j];
                    to_left_id[j] = temp;
                }
            }
        }
        match (to_right_position.first(), to_left_position.last()) {
            (Some(&right), Some(&left)) if l - right <= left => {
                println!("{} {}", left, to_left_id.last().unwrap());
            }
            (Some(&right), Some(&left)) => {
                println!("{} {}", l - right, to_right_id.first().unwrap());
            }
            (Some(&right), _) => {
                println!("{} {}", l - right, to_right_id.first().unwrap());
            }
            (_, Some(&left)) => {
                println!("{} {}", left, to_left_id.last().unwrap());
            }
            _ => unreachable!()
        }
    }
}


Measured memory_bytes: 5048