```#include [HTML_REMOVED]
using namespace std;
using ll = long long;
using pii = pair[HTML_REMOVED];
const int N = 1005;
int t, n, m, k, l, r, op, x, y;
string tmp, tmp2;
vector[HTML_REMOVED] X, X1, X2;
vector[HTML_REMOVED] cf[N];
vector[HTML_REMOVED] mul(vector[HTML_REMOVED] a, int b) {
for (int &num : a) {
num = b;
}
int carry = 0;
auto cur = a.rbegin();
while (cur != a.rend()) {
cur = cur + carry;
carry = cur / m;
*cur %= m;
cur;
}
while (carry) {
a.insert(a.begin(), carry % m);
carry /= m;
}
return a;
}
vector[HTML_REMOVED] add(vector[HTML_REMOVED] a, vector[HTML_REMOVED] b) {
int siz1 = a.size();
int siz2 = b.size();
if (siz1 < siz2) {
swap(a, b);
swap(siz1, siz2);
}
while (siz1 > siz2) {
b.insert(b.begin(), 0);
siz2;
}
int carry = 0;
for (int i = siz1 - 1; i >= 0; i–) {
a[i] = a[i] + b[i] + carry;
carry = a[i] / m;
a[i] %= m;
}
while (carry) {
a.insert(a.begin(), carry % m);
carry /= m;
}
return a;
}
void print(vector[HTML_REMOVED]&a) {
for (int num : a) {
if (num >= 10) {
cout << (char)(num + ‘a’ - 10);
} else {
cout << num;
}
}
cout << “\n”;
}
void solve() {
cin >> n >> m >> tmp;
// n 原进制
// m 转进制
int siz = tmp.size();
cf[0].push_back(1);
for (int i = 1; i < siz; i++) {
cf[i] = mul(cf[i - 1], n);
}
for (char&ch : tmp)X.push_back(ch >= ‘0’ && ch <= ‘9’ ? ch - ‘0’ : ch - ‘A’ + 10);
for (int i = 0; i < siz; i++) {
X1 = add(X1, mul(cf[siz - i - 1], X[i]));
}
print(X1);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}
```