// Arup Guha
// 5/15/2021
// Solution to 2021 Code Jam Round 2 Problem A: Minimum Sort
// Written in contest commented later.

import java.util.*;

public class Solution {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		int n = stdin.nextInt();
		
		// Process cases.
		for (int loop=1; loop<=nC; loop++) {
			
			// We will find the minimum value for position i.
			for (int i=1; i<n; i++) {
				
				// Safe to query the whole range due to harmonic sum being small enough.
				System.out.println("M "+i+" "+n);
				System.out.flush();
				
				// Get where the current minimum is.
				int loc = stdin.nextInt();
				
				// If it's in the wrong spot, swap it into the right spot.
				if (loc > i) {
					System.out.println("S "+i+" "+loc);
					System.out.flush();
					int dummy = stdin.nextInt();
				}
			}
			
			// Done with the case, continue.
			System.out.println("D");
			System.out.flush();
			int dummy = stdin.nextInt();
			if (dummy == -1) break;
		}
	}
}