#include <bits/stdc++.h>
using namespace std;
namespace TYC {
int S, T, mod;
vector<int> tmp;
map<int, vector<int> > V;
inline int qpow(int x, int tim) {
  int ans = 1;
  for (; tim; tim >>= 1, x = int((long long)x * x % mod))
    if (tim & 1) ans = int((long long)ans * x % mod);
  return ans;
}
void getnum(int &v) {
  tmp.clear();
  for (int i = 1; i <= 100; i++) {
    int k = rand() % 3 + 1;
    if (k == 1)
      v = (v + 1) % mod;
    else if (k == 2)
      v = (v - 1 + mod) % mod;
    else
      v = qpow(v, mod - 2);
    tmp.push_back(k);
  }
}
void print(vector<int> A, vector<int> B) {
  puts("200");
  for (int p : A) printf("%d ", p);
  reverse(B.begin(), B.end());
  for (int p : B) printf("%d ", p == 1 ? 2 : (p == 2 ? 1 : 3));
  puts("");
}
void work() {
  scanf("%d%d%d", &S, &T, &mod);
  int cnt = 1e5;
  for (int i = 1; i <= cnt; i++) {
    int v = S;
    getnum(v);
    V[v] = tmp;
  }
  for (int i = 1; i <= cnt; i++) {
    int v = T;
    getnum(v);
    if (V.count(v)) return print(V[v], tmp);
  }
}
}  // namespace TYC
int main() {
  TYC::work();
  return 0;
}
