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

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

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

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

g = A("g")
d = B("d")
h = C("h")
j = D("j")
e = D("e")
m = C("m")

g.r = j
g.p = j
g.z = e
d.x = h
d.y = g
h.o = m
h.u = m
j.s = m
e.s = h
m.o = h
m.u = h
assert m.o.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.z: D = None
        self.p: D = None
        self.txt = txt

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

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

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

g = A("g")
d = B("d")
h = C("h")
j = D("j")
e = D("e")
m = C("m")

g.r = j
g.p = j
g.z = e
d.x = h
d.y = g
h.o = m
h.u = m
j.s = m
e.s = h
m.o = h
m.u = h
assert m.o.o.u.txt == "h"