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

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

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

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

c = A("c")
l = B("l")
d = C("d")
n = D("n")

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

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

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

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

c = A("c")
l = B("l")
d = C("d")
n = D("n")

c.y = l
l.q = n
l.t = c
l.p = d
l.o = d
d.v = c
n.t = l
assert d.v.y.t.y.txt == "l"