#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

int main(){
    int n;
    cin >> n;
    int m = (1<<n);
    vector<string> res;
    rep(bits,1<<n){
        if(bits==0)continue;
        vector<bool> flag(m);
        rep(i,m){
            int c = 0;
            rep(j,n){
                if((bits>>j)&1){
                    if((i>>j)&1)c++;
                }
            }    
            if(c%2==1)flag[i] = 1;
        }
        string s;
        rep(i,m){
            if(flag[i]){
                s.push_back('A');
            }else{
                s.push_back('B');
            }
        }
        res.push_back(s);
    }
    cout << res.size() << "\n";
    for(auto x:res){
        cout << x << "\n";
    }
    return 0;
}
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;



int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll n;
  unordered_map<ll, int>st;
  ll cur = 5;
  cin>>n;
  int cnt = 1;
  while(cur<=n){
    st[cur] = cnt;
    cur*=5;
    cnt++;
  }
  int cnt2 = 1;
  cur = 3;
  while(cur<n){
    if(st.find(n-cur)!=st.end()){
      cout<<cnt2<<" "<<st[n-cur]<<endl;
      return 0;
    }
    cur *=3;
    cnt2++;
  }
  cout<<-1<<endl;
  return 0;
}
