#include <iostream>
#include <utility>

using namespace std;

namespace details {
	template <class T1, class T2>
	struct tie{
		T1& first;
		T2& second;
		
		tie(T1& x, T2& y) : first(x), second(y) {}

		tie<T1, T2>& operator=(const pair<T1, T2>& rhs){
			first = rhs.first;
			second = rhs.second;

			return *this;
		}
	};
}

template <class T1, class T2>
details::tie<T1, T2> tie(T1& x, T2& y) { 
	return details::tie<T1, T2>(x, y);
} 

pair<int, int> test() {
    return make_pair(13, 42);
}

int main() {
	int a = 1, b = 2;
	int c = 3, d = 4;

	details::tie<int, int>(a, b) = test();
	tie(c, d) = test();

 
	cout << a << ' ' << b << endl << c << ' ' << d << endl;

}