#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<long long> ans_u;
vector<long long> ans_v;
long long p;
vector<long long> solve(long long u) {
  vector<long long> ans;
  if (u == 0) {
    ans.push_back(1);
    return ans;
  }
  while (true) {
    ans.clear();
    long long k = (rng() % p + p) % p;
    long long a = ((k * u) % p + p) % p;
    long long b = (k % p + p) % p;
    if (k == 0) continue;
    while (a != b) {
      if (a < b) {
        swap(a, b);
        ans.push_back(3);
      } else {
        a -= b;
        ans.push_back(2);
      }
      if (ans.size() > 100) break;
    }
    if (ans.size() <= 100) return ans;
  }
}
signed main() {
  long long u, v;
  cin >> u >> v >> p;
  vector<long long> ans_u = solve(u);
  vector<long long> ans_v = solve(v);
  reverse(ans_v.begin(), ans_v.end());
  cout << ans_u.size() + ans_v.size() << endl;
  for (long long i : ans_u) cout << i << ' ';
  for (long long i : ans_v) {
    if (i == 2)
      cout << 1 << ' ';
    else if (i == 1)
      cout << 2 << ' ';
    else
      cout << i << ' ';
  }
}
