Decide existence of total orderings In this task, we consider arrays of positive integers such as this:

3 18 321 17 4 4 51 1 293 17


The input comprises a pair of such arrays both of arbitrary, possibly distinct, positive length. Determine if a total ordering &le;X &subset; N &times; N, where N is the set of positive integers, exists such that both input arrays are in order with respect to &le;X.  Notice that (A &le;X B &and; B &le;X A) &harr; A = B must hold, that is, two numbers are considered equal under &le;X if and only if they are the same number.

For example, if the input was the pair of arrays

7 2 1 1 4 12 3
9 8 7 2 5 1


then you are supposed to figure out if a total ordering &le;X exists such that


  7 &le;X 2 &le;X 1 &le;X 1 &le;X 4 &le;X 12 &le;X 3


and


  9 &le;X 8 &le;X 7 &le;X 2 &le;X 5 &le;X 1.


Your submission may be a subroutine or program that receives two arrays (as specified above) of input in an implementation-defined way, computes whether a total ordering &le;X satisfying the demands mentioned above exists and returns one value representing “yes” or a different value representing “no.” The choice of these values is arbitrary, please document them.

You may assume that the input arrays contain no more than 215 - 1 elements each and that each of their elements is in the range from 1 to 215 - 1 inclusive. You may require each arrays to be terminated by a constant sentinel outside of the aforementioned range such as 0. Please specify what sentinel is needed. You may require the lengths of the arrays as additional input if the length cannot be inferred from the arrays themselves (e.&thinsp;g. in languages like C). In addition to the prohibition of standard loopholes, you are not allowed to use topological sorting routines.

This challenge is code golf. The submission with the least amount of characters wins.
Pyth, 28 22
L.AmqdSdmfhTmxhkbek^b2

Creates a function y that you can call with a tuple containing the two arrays. Returns &quot;True&quot; if a total ordering exists, &quot;False&quot; if not.
A helper program that defines and calls the above function with stdin:
L.AmqdSdmfhTmxhkbek^b2y,rw7rw7 

Try it here.
We first read both arrays. Then we will create all combinations of both arrays. Then for each combination we will assume the first array is authoritative, and check if it's consistent with the second array.