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

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

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

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

m = A("m")
d = B("d")
f = C("f")
b = D("b")
g = A("g")
n = C("n")

m.z = d
m.p = d
d.s = f
d.v = m
d.w = b
f.v = n
f.s = b
b.z = f
g.z = d
g.p = d
n.v = f
n.s = b
assert f.s.z.v.v.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: B = None
        self.txt = txt

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

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

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

m = A("m")
d = B("d")
f = C("f")
b = D("b")
g = A("g")
n = C("n")

m.z = d
m.p = d
d.s = f
d.v = m
d.w = b
f.v = n
f.s = b
b.z = f
g.z = d
g.p = d
n.v = f
n.s = b
assert f.s.z.v.v.s.z.txt == "f"