#include <iostream>

bool judge_uruyear(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 print_uruyear(int year_begin, int year_end)
{

    int count_year = 0;

    // kono for loop no jyouken-siki ha "=" hituyou!
    for(int i = year_begin; i <= year_end; i++) {
        if (judge_uruyear(i)) {
            count_year += 1;
            std::cout << i << std::endl;
        }    
    }

    if(count_year == 0) {
        std::cout << "NA" << std::endl;
    }

    std::endl(std::cout);

}

int main()
{

    int year_begin, year_end;

    while(true) {
        
        std::cin >> year_begin >> year_end;
        
        if(year_begin == 0 && year_end == 0) {
            break;
        }
        
        print_uruyear(year_begin, year_end);

    }
    
    return 0;
}