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

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.z: D = None
        self.v: B = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

k.z = e
k.y = c
b.s = e
b.z = e
b.v = a
g.s = k
g.z = k
g.o = c
g.y = c
e.r = k
c.z = e
c.y = k
a.s = e
a.z = e
a.v = b
assert k.z.r.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.z: D = None
        self.v: B = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

k.z = e
k.y = c
b.s = e
b.z = e
b.v = a
g.s = k
g.z = k
g.o = c
g.y = c
e.r = k
c.z = e
c.y = k
a.s = e
a.z = e
a.v = b
assert k.z.r.z.r.txt == "k"