#include <iostream>
#include <queue>

using namespace std;

int main(int argc, char *argv[]) {
	cout << "simulate lds visit:" << endl;
	queue< pair<int,int> > mystack;
	int depth = 1;
	int alt = 1;
	int iter  = 0;

	while ( iter < 100 ) {
		iter++;
		cout << "(" << depth << "," << alt << ") ";
		if ( depth < 3 ) {
			if ( alt == 0 )
				alt = 1;
			else
				mystack.push(make_pair(depth,0));
			depth++;		
		}
		else {
			if ( alt == 1 )
				mystack.push(make_pair(depth,0));
			if ( mystack.empty() ) break;
			cout << endl;
			pair<int,int> p = mystack.front();
			mystack.pop();
			depth = p.first;
			alt = p.second; 
		}
	}
	cout << "\nok";
	return 0;
}
