#include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) pair g(int x) { pair buf = { 0,0 }; while (x % 2 == 0) { buf.first++; x /= 2; } while (x % 5 == 0) { buf.second++; x /= 5; } return buf; } int main() { int x, y; cin >> x >> y; while (true) { pair px = g(x), py = g(y); if (abs(py.first - px.first) > abs(py.second - px.second)) { if (px.first < py.first) x *= 2; else x /= 2; } else { if (px.second < py.second) x *= 5; else x /= 5; } cout << x << endl; if (x == y) break; cin >> y; if (x == y) break; } return 0; }