#include <iostream>
#include <iomanip>
#include <vector>

typedef std::vector<int> DType;

//funny for poor license.
//if you built in the Commercial were the this code. you must pay me $10 par use.LOL!!!
//i think to better the not use for Commercial. so not use any flagment of this code.
//and you must not able to modify this ALL code.
//ふっふっふ、今度は可笑しな強制力は無いだろう。

std::size_t GetDigit(int N){
	std::size_t D = 0;

	while (N != 0){
		N /= 10;
		D++;
	}

	return D;

}

int SnipeDigit(int N, std::size_t P){
	int M = 0;
	int R = 10;

	for (std::size_t i = 0; i < P; i++){
		M = N%R;
		N /= R;
	}

	return std::abs(M);
}


int Sign(int N){
	return  N >= 0 ? 1 : -1;
}

DType MakeHoge(int A, int B){

	std::size_t BN = GetDigit(B);
	DType R;

	R.push_back(A);
	R.push_back(B);

	for (std::size_t i = 1; i <= BN; i++){
		R.push_back(std::abs(A)*SnipeDigit(B,i));
	}

	return R;
}

bool Show(DType& vec){//値がマイナスの時のことは考えてない・・・。Orz

	int MD = GetDigit(vec[0]) + GetDigit(vec[1])+1;
	int Pod = 2;
	int Mul = 1;

	std::cout << std::setw(MD) << std::right << vec[0] << std::endl;
	std::cout <<'X'<< std::setw(MD-1) << std::right << vec[1] << std::endl;
	for (int i = 0; i < MD; i++) std::cout << '-';
	std::cout<<std::endl;
	//-------
	for (std::size_t i = 0; i < vec.size()-Pod; i++){
		if (vec[Pod + i] == 0){
			Mul *= 10;
			continue;
		}
		auto T = vec[i + Pod];
		std::cout << std::setw(MD-i+GetDigit(Mul-1)) << std::right << T*Mul << std::endl;
		Mul = 1;
	}
	//-------
	for (int i = 0; i < MD; i++) std::cout << '-';
	std::cout<<std::endl;
	std::cout << std::setw(MD) << std::right << vec[0]*vec[1] << std::endl;
	return true;
}


int main(){
	DType R;

	R = MakeHoge(1234, 567);
	Show(R);
	R = MakeHoge(1234, 1001);
	Show(R);
	R = MakeHoge(99, 909090);
	Show(R);
	R = MakeHoge(12345, 12345);//両方の数が7万程度を超えると結果が32ビット超える。
	Show(R);
	return 0;

}