#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long s = 0, w = 1;     register char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();     return s * w;   }   long long n;   string s;   signed main() {     n = read();     cin >> s;     for (register long long i = 2; i <= n; i++) {       if (n % i) continue;       for (register long long j = 0; j < i / 2; j++) swap(s[j], s[i - j - 1]);     }     cout << s << endl;     return 0;   }   