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

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

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

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

k = A("k")
j = B("j")
f = C("f")
m = D("m")
e = C("e")
c = A("c")
d = B("d")
a = D("a")

k.x = e
k.s = f
k.w = c
k.v = c
j.x = k
f.z = e
f.q = c
m.z = k
m.y = f
e.z = f
e.q = k
c.x = e
c.s = f
c.w = k
c.v = k
d.x = k
a.z = k
a.y = f
assert k.x.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.s: C = None
        self.w: A = None
        self.v: A = None
        self.txt = txt

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

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

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

k = A("k")
j = B("j")
f = C("f")
m = D("m")
e = C("e")
c = A("c")
d = B("d")
a = D("a")

k.x = e
k.s = f
k.w = c
k.v = c
j.x = k
f.z = e
f.q = c
m.z = k
m.y = f
e.z = f
e.q = k
c.x = e
c.s = f
c.w = k
c.v = k
d.x = k
a.z = k
a.y = f
assert k.x.q.s.txt == "f"