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

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

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.s: A = None
        self.txt = txt

g = A("g")
l = B("l")
n = C("n")
m = D("m")
h = C("h")
e = D("e")
a = D("a")

g.x = n
l.u = g
n.z = h
n.o = g
m.r = g
m.s = g
h.z = n
h.o = g
e.r = g
e.s = g
a.r = g
a.s = g
assert h.o.x.z.z.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.s: A = None
        self.txt = txt

g = A("g")
l = B("l")
n = C("n")
m = D("m")
h = C("h")
e = D("e")
a = D("a")

g.x = n
l.u = g
n.z = h
n.o = g
m.r = g
m.s = g
h.z = n
h.o = g
e.r = g
e.s = g
a.r = g
a.s = g
assert h.o.x.z.z.o.x.txt == "n"