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

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

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

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

a = A("a")
e = B("e")
h = C("h")
d = D("d")
c = B("c")
j = D("j")
n = B("n")
i = C("i")
g = C("g")

a.x = e
e.o = a
h.u = g
d.o = n
c.o = a
j.o = c
n.o = a
i.u = g
g.u = h
assert g.u.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

a = A("a")
e = B("e")
h = C("h")
d = D("d")
c = B("c")
j = D("j")
n = B("n")
i = C("i")
g = C("g")

a.x = e
e.o = a
h.u = g
d.o = n
c.o = a
j.o = c
n.o = a
i.u = g
g.u = h
assert g.u.u.u.u.u.u.u.txt == "h"