#include <iostream>using namespace std;int main(){long long int a,b,c;while(cin>>a>>b>>c){long long int d;d=a;cout<<a<<" ";for(int e=1;e<c;e++){d=(d*d)%b;cout<<d<<" ";}cout<<endl;}}