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

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

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

f = A("f")
d = B("d")
k = C("k")
i = B("i")
h = C("h")

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

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

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

f = A("f")
d = B("d")
k = C("k")
i = B("i")
h = C("h")

f.t = h
f.w = i
f.v = k
d.s = h
d.u = f
d.w = f
k.x = h
i.s = h
i.u = f
i.w = f
h.x = k
assert f.t.x.x.x.x.txt == "h"