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

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

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

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

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

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

e.y = a
e.x = m
c.t = e
i.t = e
a.y = m
a.x = m
m.y = a
m.x = a
n.t = a
l.t = a
assert n.t.x.x.txt == "a"