unittest
{
	assert( [ "2", "1 5", "2 4", "3 6" ].parse.expand.solve == 3 );
	assert( [ "3", "1 1 1", "2 2 2", "3 3 3" ].parse.expand.solve == 27 );
	assert( [ "6", "3 14 159 2 6 53", "58 9 79 323 84 6", "2643 383 2 79 50 288" ].parse.expand.solve == 87 );
}



import std.algorithm;
import std.conv;
import std.functional;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	input.popFront;
	auto cs = input.front.split.to!( long[] );
	return tuple( as, bs, cs );
}

auto solve( long[] as, long[] bs, long[] cs )
{
	as.sort();
	bs.sort();
	cs.sort();
	
	auto r = 0L;
	auto ct = cs.length;
	foreach( a; as )
	{
		bs = bs.find!( ( x ) => a < x );
		if( bs.length == 0 ) break;
		
		cs = cs.find!( ( x ) => bs[ 0 ] < x );
		r += memoize!combination( bs, cs );
	}
	
	return r;
}

long combination( long[] bs, long[] cs )
{
	auto r = cs.length;
	
	if( 1 < bs.length )
	{
		cs = cs.find!( ( x ) => bs[ 1 ] < x );
		if( 0 < cs.length )
		{
			r += memoize!combination( bs[ 1 .. $ ], cs );
		}
	}
	
	return r;
}
