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

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

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

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

n = A("n")
j = B("j")
k = C("k")
f = D("f")
b = A("b")
g = D("g")

n.z = k
j.q = b
j.y = k
j.z = g
k.x = f
k.v = n
k.y = j
f.z = j
f.x = g
f.o = g
f.s = g
b.z = k
g.z = j
g.x = f
g.o = f
g.s = f
assert b.z.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

n = A("n")
j = B("j")
k = C("k")
f = D("f")
b = A("b")
g = D("g")

n.z = k
j.q = b
j.y = k
j.z = g
k.x = f
k.v = n
k.y = j
f.z = j
f.x = g
f.o = g
f.s = g
b.z = k
g.z = j
g.x = f
g.o = f
g.s = f
assert b.z.v.z.txt == "k"