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

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

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

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

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

c.q = f
c.r = a
c.u = n
d.u = a
d.r = a
d.z = f
d.t = c
f.u = a
f.w = a
f.y = c
a.u = n
a.q = c
a.p = d
a.y = i
n.q = f
n.r = a
n.u = c
i.u = a
i.w = a
i.y = n
assert d.u.y.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.r: D = None
        self.u: A = None
        self.txt = txt

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

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

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

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

c.q = f
c.r = a
c.u = n
d.u = a
d.r = a
d.z = f
d.t = c
f.u = a
f.w = a
f.y = c
a.u = n
a.q = c
a.p = d
a.y = i
n.q = f
n.r = a
n.u = c
i.u = a
i.w = a
i.y = n
assert d.u.y.y.r.txt == "a"