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

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

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

h = A("h")
g = B("g")
k = C("k")
f = B("f")

h.v = f
h.t = f
g.w = k
g.x = k
g.s = h
k.z = f
k.v = h
f.w = k
f.x = k
f.s = h
assert f.s.v.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.t: B = None
        self.txt = txt

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

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

h = A("h")
g = B("g")
k = C("k")
f = B("f")

h.v = f
h.t = f
g.w = k
g.x = k
g.s = h
k.z = f
k.v = h
f.w = k
f.x = k
f.s = h
assert f.s.v.s.t.txt == "f"