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

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

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

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

m = A("m")
c = B("c")
b = C("b")
a = D("a")
g = C("g")
d = B("d")

m.o = a
m.r = a
m.u = a
m.q = c
c.t = m
c.z = m
c.r = a
b.x = m
a.p = c
a.s = d
g.x = m
d.t = m
d.z = m
d.r = a
assert c.r.p.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.r: D = None
        self.q: B = None
        self.u: D = None
        self.txt = txt

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

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

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

m = A("m")
c = B("c")
b = C("b")
a = D("a")
g = C("g")
d = B("d")

m.o = a
m.r = a
m.u = a
m.q = c
c.t = m
c.z = m
c.r = a
b.x = m
a.p = c
a.s = d
g.x = m
d.t = m
d.z = m
d.r = a
assert c.r.p.r.p.txt == "c"