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

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

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: C = None
        self.w: B = None
        self.txt = txt

e = A("e")
f = B("f")
k = C("k")
j = A("j")
h = B("h")
d = C("d")

e.z = h
f.v = k
k.t = f
k.p = d
k.w = h
j.z = h
h.v = k
d.t = f
d.p = k
d.w = h
assert f.v.t.v.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: C = None
        self.w: B = None
        self.txt = txt

e = A("e")
f = B("f")
k = C("k")
j = A("j")
h = B("h")
d = C("d")

e.z = h
f.v = k
k.t = f
k.p = d
k.w = h
j.z = h
h.v = k
d.t = f
d.p = k
d.w = h
assert f.v.t.v.w.v.txt == "k"