private static void runConsole() throws Exception {
        while (true) {
            System.out.printf(">> ");
            String rawCommand = System.console().readLine();
            String command = rawCommand.toUpperCase().trim();

            if (command.startsWith("Q") || command.startsWith("EXIT")) {
                System.out.printf("Exiting...\r\n\r\n\r\n");
                return;
            }

            if (command.startsWith("T9")) {
                try {
                    String[] groups = command.split("\\s+");
                    if (groups.length <= 1) {
                        System.out.println(usage);
                    }
                    T9 t9 = T9Factory.getT9Instance();
                    List<List<String>> res = t9.GetMatchingList(groups);
                    System.out.println(res);
                } catch (Exception e) {
                    e.printStackTrace();
                    System.out.println("ERROR: " + e.getMessage());
                }
            }
            else if (command.startsWith("MAGIC")){
                try {
                    String[] input = command.split("\\s+");
                    if(input.length != 2) {
                        System.out.println(usage);
                    }
                    int n = Integer.parseInt(input[1]);
                    MagicSquare square = MagicSquareFactory.getMagicSquareInstance(n);
                    square.print(n);
                }
                catch(Exception e) {
                    e.printStackTrace();
                    System.out.println("ERROR: " + e.getMessage());
                }
            }
            else {
                System.out.println(usage);
            }
        }

    }