package laba5;

import java.util.Scanner;

public class example7 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // ===== Timus 1197 — Lonesome Knight =====
        System.out.println("Задача Timus 1197 (Lonesome Knight)");
        System.out.print("Введите количество позиций: ");
        int t = scanner.nextInt();
        scanner.nextLine();

        for (int k = 0; k < t; k++) {
            System.out.print("Введите позицию коня (например, a1): ");
            String pos = scanner.nextLine();

            int x = pos.charAt(0) - 'a' + 1;
            int y = pos.charAt(1) - '0';

            int[][] moves = {
                    {2, 1}, {2, -1}, {-2, 1}, {-2, -1},
                    {1, 2}, {1, -2}, {-1, 2}, {-1, -2}
            };

            int count = 0;
            for (int[] m : moves) {
                int nx = x + m[0];
                int ny = y + m[1];
                if (nx >= 1 && nx <= 8 && ny >= 1 && ny <= 8) {
                    count++;
                }
            }

            System.out.println("Количество ходов: " + count);
        }

        // ===== Timus 2100 — Wedding Dinner =====
        System.out.println("\nЗадача Timus 2100 (Wedding Dinner)");
        System.out.print("Введите количество приглашённых: ");
        int guests = scanner.nextInt();
        scanner.nextLine();

        int pairs = 0;
        for (int i = 0; i < guests; i++) {
            String name = scanner.nextLine();
            if (name.endsWith("+one")) {
                pairs++;
            }
        }

        int totalPeople = guests + pairs + 2;
        int cost = totalPeople * 100;

        if (cost == 1300) {
            cost = 1400;
        }

        System.out.println("Стоимость ужина: " + cost);

        scanner.close();
    }
}