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

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

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

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

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

n.t = i
l.o = d
i.v = d
i.y = n
d.q = n
d.z = e
d.p = i
d.t = l
e.q = n
e.z = d
e.p = i
e.t = l
assert l.o.q.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

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

n.t = i
l.o = d
i.v = d
i.y = n
d.q = n
d.z = e
d.p = i
d.t = l
e.q = n
e.z = d
e.p = i
e.t = l
assert l.o.q.t.y.txt == "n"