p115.cpp
======================
#include <bits/stdc++.h>
#define endl '\n'

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#define SZ(x) ((int)x.size())
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back

using namespace std;
template<class T, class T2>
inline int chkmax(T& x, const T2& y) {
    return x < y ? x = y, 1 : 0;
}
template<class T, class T2>
inline int chkmin(T& x, const T2& y) {
    return x > y ? x = y, 1 : 0;
}
const int MAXN = (1 << 20);

int m, n;

void read() { cin >> n >> m; }

vector<int> months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void solve() {
    if(m <= 0 || n <= 0 || m > 12 || n > months[m - 1]) {
        cout << "Impossible" << endl;
        return;
    }

    n--;
    for(int i = 1; i < m; i++) {
        n += months[i - 1];
    }
    cout << (n % 7) + 1 << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    read();
    solve();
    return 0;
}

=================
statement.txt
======================
115. Calendar

time limit per test: 0.25 sec.
memory limit per test: 4096 KB


First year of new millenium is gone away. In commemoration of it write a program that finds the name of the day of the week for any date in 2001.


Input

Input is a line with two positive integer numbers N and M, where N is a day number in month M. N and M is not more than 100.


Output

Write current number of the day of the week for given date (Monday – number 1, … , Sunday – number 7) or phrase “Impossible” if such date does not exist.


Sample Input

21 10
Sample Output

7
Author	: Michael R. Mirzayanov
Resource	: PhTL #1 Training Contests
Date	: January 2002


=================
