#include <vector> #include <iostream> #include <map> #include <algorithm> #define ll long long #define all(x) x.begin(), x.end() #define ve vector #define vi vector<int> #define vvi vector<vector<int>> #define pb push_back #define pii pair<int, int> using namespace std; template <class T> istream& operator >>(istream&in, vector<T>&v) { for(T&el : v) { in >> el; } return in; } template <class T> ostream& operator <<(ostream&out, vector<T>&v) { out <<"{"; for(T&el : v) { out << el << ' '; } out <<"}"; return out; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ve<pair<ll, pii>> conv; int LIM = 2025; conv.reserve(LIM*LIM); ve<ve<ll>> table(LIM, ve<ll>(LIM)); for (int i = 1; i < LIM; ++i) { for (int j = i; j < LIM; ++j) { table[i][j] = (ll)i * j * (i - 1) * (j - 1) / 4; ll nm = table[i][j]; conv.pb({table[i][j], {i, j}}); } } sort(all(conv)); reverse(all(conv)); ve<ll> hss(conv.size()); for (int i = 0; i < hss.size(); ++i) hss[i] = conv[i].first; ve<string> res; ll x; cin >> x; if (x == 0) { cout << "1 1\n.\n"; return 0; } ve<tuple<int, int, int, int>> emptyspaces; while (x != 0) { int ind = lower_bound(all(hss), x, greater<ll>()) - hss.begin(); x -= hss[ind]; auto [h, w] = conv[ind].second; int an = -1; for (int i = 0; i < emptyspaces.size(); ++i) { auto [ys, xs, y0, x0] = emptyspaces[i]; if (ys >= h && xs >= w) { an = i; break; } } if (an != -1) { auto [ys, xs, y0, x0] = emptyspaces[an]; emptyspaces.erase(emptyspaces.begin() + an); for (int i = y0; i < y0 + h; ++i) { for (int j = x0; j < x0 + w; ++j) { res[i][j] = '#'; } } if (xs >= w + 4) { emptyspaces.emplace_back(ys, xs - w - 1, y0, x0 + w + 1); } } else { int y00 = res.size(); if (w+4 <= LIM) { emptyspaces.emplace_back(h, LIM - w - 2, res.size(), w+2); } for (int i = 0; i < h; ++i) { string s; for (int j = 0; j < w; ++j) s += '#'; for (int j = w; j < LIM; ++j) s += '.'; res.pb(s); } int rest = h, cur = y00; for (int j = 2; j >= 2; --j) { ll sf = (ll)j * (j - 1) / 2 * w; while (j <= rest && x >= sf) { for (int j0 = cur; j0 < cur + j; ++j0) { res[j0][w] = '#'; } cur += j+1; rest -= j+1; x -= sf; } } res.pb(string(LIM, '.')); } } cout << res.size() << ' ' << res[0].size() << "\n"; for (auto s : res) cout << s << "\n"; }