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

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

k = A("k")
c = B("c")
m = A("m")
f = B("f")
i = B("i")

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

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

k = A("k")
c = B("c")
m = A("m")
f = B("f")
i = B("i")

k.w = m
k.s = f
c.t = k
m.w = k
m.s = c
f.t = m
i.t = k
assert i.t.w.w.txt == "k"