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

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

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

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

j = A("j")
f = B("f")
a = C("a")
k = D("k")
b = A("b")
m = D("m")

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

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

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

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

j = A("j")
f = B("f")
a = C("a")
k = D("k")
b = A("b")
m = D("m")

j.z = a
j.p = a
j.x = a
j.v = m
f.q = m
a.v = f
a.s = f
a.z = b
k.x = a
k.y = a
k.z = f
b.z = a
b.p = a
b.x = a
b.v = k
m.x = a
m.y = a
m.z = f
assert k.y.z.v.z.txt == "f"