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

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

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

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

k.t = a
f.w = a
f.o = h
f.s = h
a.y = f
a.p = h
a.v = h
h.y = f
h.p = a
h.v = a
assert a.v.y.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

k.t = a
f.w = a
f.o = h
f.s = h
a.y = f
a.p = h
a.v = h
h.y = f
h.p = a
h.v = a
assert a.v.y.o.y.txt == "f"