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

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

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

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

n = A("n")
j = B("j")
a = C("a")
d = D("d")
e = C("e")

n.t = j
n.s = j
n.r = a
j.o = n
j.y = n
j.u = n
j.v = e
a.q = e
a.o = e
a.z = n
d.s = e
e.q = a
e.o = a
e.z = n
assert d.s.q.q.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: B = None
        self.r: C = None
        self.txt = txt

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

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

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

n = A("n")
j = B("j")
a = C("a")
d = D("d")
e = C("e")

n.t = j
n.s = j
n.r = a
j.o = n
j.y = n
j.u = n
j.v = e
a.q = e
a.o = e
a.z = n
d.s = e
e.q = a
e.o = a
e.z = n
assert d.s.q.q.z.r.txt == "a"