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

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

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

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

c = A("c")
k = B("k")
d = C("d")
g = D("g")

c.z = d
k.t = d
k.v = d
k.o = c
k.y = g
d.z = k
d.r = k
g.q = d
assert k.o.z.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

c = A("c")
k = B("k")
d = C("d")
g = D("g")

c.z = d
k.t = d
k.v = d
k.o = c
k.y = g
d.z = k
d.r = k
g.q = d
assert k.o.z.z.v.txt == "d"