#include using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); long long T, B; cin >> T >> B; long long b = -B; vector Ns(T, 0); for (auto & n: Ns) cin >> n; for (auto n : Ns){ if (n == 0){ cout << "0/n"; continue; } vector ans; int sign = 1; while (n > 0){ if (sign == 1){ ans.push_back(n % b); n /= b; sign = -1; }else{ int tmp = (b - (n % b)) % b; ans.push_back(tmp); n = (n + tmp)/b; sign = 1; } } for (auto it = ans.rbegin(); it != ans.rend(); ++it) cout << *it; cout << '\n'; } return 0; }