#include <iostream>

bool inputValCheck(int input_n1, input_n2);
void printLeapYear(int start_y, int end_y);
bool isLeapYear(int year);


int main()
{
    int start_year, end_year;
    std::cin >> start_year >> end_year;
    if (inputValCheck(start_year, end_year)) {
        printLeapYear(start_year, end_year);
    }
    return 0;
}

bool inputValCheck(int input_n1, int input_n2);
{
    if (input_n1 <= 0 || input_n1 > input_n2 || input_n2 >= 1000) {
        return false;
    }
    return true;
}


bool isLeapYear(int year)
{
    if (year % 400 == 0) {
        return true;
    } else if (year % 100 == 0) {
        return false;
    } else if (year % 4 == 0) {
        return true;
    } else {
        return false;
    }
}

void printLeapYear(int start_y, int end_y)
{
    bool is_leap_year = false;
    for (int i = start_y; i <= end_y; i++) {
        if (isLeapYear(i) == true) {
            std::cout << i << std::endl;
        }
    }
}