#include<stdio.h>
#include<assert.h>

#define N 7
#define ALLOWED_CHANGES 2

int X[N][N][N];
long cnt = 0;

inline int test_valid(int a,int b,int c)
{
	int i,j,k,l;
	int scenario=0;
	for(int d=0;d<c;d++)
	{
		if(d == a || d == b || d == c) continue;
		if(d<a)
		{
			i = d; j = a; k = b; l = c;
			scenario = 1;
		}
		else
		{
			if(d<b)
			{
				i = a; j = d; k = b; l = c;
				scenario = 2;
			}
			else // d<c since c is maximal element
			{
				i = a; j = b; k = d; l = c;
				scenario = 3;
			}
		}

		int s1 = X[i][j][k];
		int s2 = X[i][j][l];
		int s3 = X[i][k][l];
		int s4 = X[j][k][l];
		if(s1 == 0 || s2 == 0 || s3 == 0 || s4 == 0) continue;

		int changes = 0;
		if(s1*s2 < 0) changes++;
		if(s2*s3 < 0) changes++;
		if(s3*s4 < 0) changes++;
		if(changes > ALLOWED_CHANGES) assert(scenario == 1); // i guess there is a simple argument for this
		if(changes > ALLOWED_CHANGES) return 0;

	}
	return 1;
}

inline int display()
{
	cnt++;
	printf("#%ld: ",cnt);
	for(int a=0;a<N;a++)
	{
		for(int b=a+1;b<N;b++)
		{
			for(int c=b+1;c<N;c++)
			{
				printf(X[a][b][c] > 0 ?"+":"-");
			}	
		}			
	}
	printf("\n");
}

int rec_fill(int a,int b,int c)
{
	if(a == b) 
	{
		a = 0;
		b++;
		if(b == c)
		{
			b = 1;
			c++;
		}
	}

	if(c == N)
	{
		display();
	}
	else
	{
		for(int v=-1;v<=+1;v+=2)
		{
			X[a][b][c] = v;
			if(test_valid(a,b,c)) rec_fill(a+1,b,c);
			X[a][b][c] = 0;
		}		
	}
}

int init_zeros()
{
	for(int a=0;a<N;a++)
	{
		for(int b=a+1;b<N;b++)
		{
			for(int c=b+1;c<N;c++)
			{
				X[a][b][c] = 0;
			}
		}
	}
}

int main()
{
	init_zeros();
	rec_fill(0,1,2);
}