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

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

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

i = A("i")
k = B("k")
j = C("j")
f = A("f")

i.t = k
k.s = j
k.w = i
j.p = k
f.t = k
assert f.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

i = A("i")
k = B("k")
j = C("j")
f = A("f")

i.t = k
k.s = j
k.w = i
j.p = k
f.t = k
assert f.t.w.t.txt == "k"