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

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

g = A("g")
i = B("i")
n = B("n")
l = A("l")
j = A("j")
d = A("d")
e = B("e")
f = B("f")
h = A("h")

g.u = d
i.o = l
i.t = l
n.o = j
n.t = h
l.u = h
j.u = g
d.u = h
e.o = d
e.t = h
f.o = d
f.t = j
h.u = l
assert d.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

g = A("g")
i = B("i")
n = B("n")
l = A("l")
j = A("j")
d = A("d")
e = B("e")
f = B("f")
h = A("h")

g.u = d
i.o = l
i.t = l
n.o = j
n.t = h
l.u = h
j.u = g
d.u = h
e.o = d
e.t = h
f.o = d
f.t = j
h.u = l
assert d.u.u.u.u.txt == "l"