#include <bits/stdc++.h>
using namespace std;
int U, V, P;
long long path[50005][105];
long long A[105];
map<long long, int> mp;
long long expo(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  if (b % 2 == 0) return expo(a * a % P, b / 2);
  return a * expo(a * a % P, (b - 1) / 2) % P;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> U >> V >> P;
  if (U == V) {
    cout << "0\n";
    return 0;
  }
  int sq = sqrt(P);
  for (int i = 0; i < sq; i++) {
    long long cur = U;
    for (int j = 0; j < 100; j++) {
      path[i][j] = rand() % 3 + 1;
      if (path[i][j] == 1)
        cur = (cur + 1) % P;
      else if (path[i][j] == 2)
        cur = (cur + P - 1) % P;
      else
        cur = expo(cur, P - 2);
      if (cur == V) {
        cout << j + 1 << "\n";
        for (int k = 0; k <= j; k++) cout << path[i][k] << " ";
        cout << "\n";
        return 0;
      }
    }
    mp[cur] = i;
  }
  while (true) {
    long long cur = V;
    for (int i = 0; i < 100; i++) {
      A[i] = rand() % 3 + 1;
      if (A[i] == 1)
        cur = (cur + P - 1) % P;
      else if (A[i] == 2)
        cur = (cur + 1) % P;
      else
        cur = expo(cur, P - 2);
      if (mp.count(cur)) {
        cout << i + 101 << "\n";
        int idx = mp[cur];
        for (int j = 0; j < 100; j++) cout << path[idx][j] << " ";
        for (int j = i; j >= 0; j--) cout << A[j] << " ";
        cout << "\n";
        return 0;
      }
    }
  }
  return 0;
}
