// Arup Guha
// 11/14/2015
// Solution to 2015 SER D2 Problem: Egg Drop

import java.util.*;

public class eggdrop {

	public static void main(String[] args) {

		// Read in input.
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int maxFloor = stdin.nextInt();

		// Run through data.
		int safe = 1, broken = maxFloor;
		for (int i=0; i<n; i++) {

			// Get result of next experiment.
			int floor = stdin.nextInt();
			boolean isSafe = stdin.next().equals("SAFE");

			// Update max safe floor or min broken floor, if necessary.
			if (isSafe) safe = Math.max(safe, floor);
			if (!isSafe) broken = Math.min(broken, floor);
		}

		// Output result.
		System.out.println((safe+1)+" "+(broken-1));
	}
}