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

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

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

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

d = A("d")
e = B("e")
b = C("b")
i = D("i")
m = D("m")
n = C("n")

d.y = i
d.q = e
e.z = n
e.t = d
b.x = d
b.r = m
i.p = e
i.z = d
i.o = d
i.y = b
m.p = e
m.z = d
m.o = d
m.y = n
n.x = d
n.r = m
assert d.y.y.x.q.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.q: B = None
        self.txt = txt

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

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

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

d = A("d")
e = B("e")
b = C("b")
i = D("i")
m = D("m")
n = C("n")

d.y = i
d.q = e
e.z = n
e.t = d
b.x = d
b.r = m
i.p = e
i.z = d
i.o = d
i.y = b
m.p = e
m.z = d
m.o = d
m.y = n
n.x = d
n.r = m
assert d.y.y.x.q.z.r.txt == "m"