class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.z: A = None
        self.txt = txt

e = A("e")
m = B("m")
i = B("i")
g = A("g")
a = A("a")
l = A("l")
n = A("n")
c = A("c")
b = A("b")
k = B("k")

e.t = k
m.x = n
m.z = n
i.x = a
i.z = a
g.t = m
a.t = i
l.t = k
n.t = m
c.t = i
b.t = m
k.x = c
k.z = n
assert k.x.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.z: A = None
        self.txt = txt

e = A("e")
m = B("m")
i = B("i")
g = A("g")
a = A("a")
l = A("l")
n = A("n")
c = A("c")
b = A("b")
k = B("k")

e.t = k
m.x = n
m.z = n
i.x = a
i.z = a
g.t = m
a.t = i
l.t = k
n.t = m
c.t = i
b.t = m
k.x = c
k.z = n
assert k.x.t.x.txt == "a"