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

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

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

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

n = A("n")
a = B("a")
k = C("k")
b = D("b")
c = B("c")

n.t = c
a.q = b
a.r = b
a.p = k
a.o = k
k.z = n
b.q = c
b.t = a
b.y = k
c.q = b
c.r = b
c.p = k
c.o = k
assert c.q.t.r.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

n = A("n")
a = B("a")
k = C("k")
b = D("b")
c = B("c")

n.t = c
a.q = b
a.r = b
a.p = k
a.o = k
k.z = n
b.q = c
b.t = a
b.y = k
c.q = b
c.r = b
c.p = k
c.o = k
assert c.q.t.r.y.z.txt == "n"