#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ff first
#define ss second
#define szof(x) ((int)x.size())
#ifndef LOCAL
#  define cerr __get_ce
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned long long ull;

using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;

int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;

#ifdef LOCAL
	mt19937 tw(9450189);
#else
	mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
uniform_int_distribution<ll> ll_distr;
ll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }

int MOD;

void add(int& a, int b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

int sum(int a, int b) {
	add(a, b);
	return a;
}

int mult(int a, int b) {
	return (ll) a * b % MOD;
}

bool is_prime(int x) {
	for (int i = 2; i * i <= x; ++i) {
		if (x % i == 0) {
			return false;
		}
	}
	return true;
}

int get_val_modulo(string num) {
	int ret = 0;
	for (char d : num) {
		ret = sum(mult(ret, 10), d - '0');
	}
	return ret;
}

void solve() {
	do {
		MOD = rnd(INF / 2, INF);
	} while (!is_prime(MOD));

	string ab, c;
	cin >> ab >> c;

	vector<int> p10 = {1};
	for (int i = 0; i < szof(ab); ++i) {
		p10.push_back(mult(p10.back(), 10));
	}

	int a_val = 0;
	int b_val = get_val_modulo(ab);
	int c_val = get_val_modulo(c);
	for (int i = 0; i < szof(ab) - 1; ++i) {
		a_val = sum(mult(a_val, 10), ab[i] - '0');

		add(b_val, MOD - mult(p10[szof(ab) - i - 1], ab[i] - '0'));

		if (mult(b_val, c_val) == a_val) {
			cout << ab.substr(0, i + 1) << " " << ab.substr(i + 1) << "\n";
			return;
		}
	}
}


int main() {
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	cout << setprecision(15) << fixed;
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
 
	int test_count = 1;
	// cin >> test_count;
	for (int test = 1; test <= test_count; ++test) {
		solve();
	}
	
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int) 1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}