#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
enum { MOD0 = 1000000000, MOD7 = 1000000007, MOD9 = 1000000009 };
int inv(long long a, int m) {
  int b = m - 2;
  long long ret = 1;
  while (b) {
    if (b & 1) {
      ret *= a;
      ret %= m;
    }
    b >>= 1;
    a *= a;
    a %= m;
  }
  return ret;
}
int perform_action(int x, int y, int m) {
  if (y == 1) {
    return (x + 1) % m;
  } else if (y == 2) {
    return (x + m - 1) % m;
  } else {
    return inv(x, m);
  }
}
bool gcd(int x, int y, int ans[100], int *sz) {
  if (!x || !y) {
    return 0;
  }
  *sz = 0;
  while (x && y) {
    if (*sz == 100) {
      return 0;
    }
    if (x >= y) {
      x -= y;
      ans[(*sz)++] = 2;
    } else if (x < y) {
      swap(x, y);
      ans[(*sz)++] = 3;
    }
  }
  return 1;
}
int ans[2][100];
int sz[2];
void find_path(int x, int m, int ans[100], int *sz) {
  if (x == 0) {
    *sz = 0;
    return;
  }
  int v;
  do {
    v = (rand() << 16) | rand() % m;
  } while (!gcd((long long)v * x % m, v, ans, sz));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(time(0));
  int u, v, m;
  cin >> u >> v >> m;
  find_path(u, m, ans[0], &sz[0]);
  find_path(v, m, ans[1], &sz[1]);
  cout << sz[0] + sz[1] << '\n';
  for (int i = 0; i < sz[0]; ++i) {
    cout << ans[0][i] << " ";
  }
  for (int i = sz[1] - 1; i >= 0; --i) {
    cout << (ans[1][i] == 2 ? 1 : 3) << " ";
  }
  cout << '\n';
  return 0;
}
