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

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

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

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

c = A("c")
i = B("i")
m = C("m")
d = D("d")
a = D("a")
n = B("n")

c.x = m
c.y = i
c.q = a
i.o = c
i.u = m
i.x = d
m.x = d
d.x = m
d.y = c
d.z = c
d.u = a
a.x = m
a.y = c
a.z = c
a.u = d
n.o = c
n.u = m
n.x = a
assert d.x.x.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: B = None
        self.q: D = None
        self.txt = txt

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

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

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

c = A("c")
i = B("i")
m = C("m")
d = D("d")
a = D("a")
n = B("n")

c.x = m
c.y = i
c.q = a
i.o = c
i.u = m
i.x = d
m.x = d
d.x = m
d.y = c
d.z = c
d.u = a
a.x = m
a.y = c
a.z = c
a.u = d
n.o = c
n.u = m
n.x = a
assert d.x.x.u.u.txt == "d"