class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: A = None
        self.txt = txt

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

e = A("e")
g = B("g")
c = B("c")
m = B("m")
l = A("l")
h = B("h")

e.o = l
e.u = l
g.x = e
c.x = e
m.x = e
l.o = e
l.u = e
h.x = l
assert g.x.u.o.u.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: A = None
        self.txt = txt

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

e = A("e")
g = B("g")
c = B("c")
m = B("m")
l = A("l")
h = B("h")

e.o = l
e.u = l
g.x = e
c.x = e
m.x = e
l.o = e
l.u = e
h.x = l
assert g.x.u.o.u.o.o.txt == "l"