#include <iostream>
#include <fstream>
#include <list>
using namespace std;
ifstream fin("round.in");
int main() {
int N,T;
while (true) {
fin >> N;
if (N == 0) break;
fin >> T;
int count=0;
list<int> game(N,0); list<int>::iterator cur = game.begin();
do {
for (int j=0; j < T-1; j++) { ++cur;
if (cur == game.end()) {
count++; cur = game.begin();
}
}
cur = game.erase(cur); if (cur == game.end()) {
count++;
cur = game.begin();
}
} while (cur != game.begin());
cout << game.size() << " " << count << endl;
}
}