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

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

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

k = A("k")
a = B("a")
f = C("f")
b = A("b")
i = C("i")

k.u = a
k.w = b
a.s = b
a.x = b
f.u = k
f.s = i
b.u = a
b.w = k
i.u = k
i.s = f
assert i.u.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: A = None
        self.txt = txt

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

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

k = A("k")
a = B("a")
f = C("f")
b = A("b")
i = C("i")

k.u = a
k.w = b
a.s = b
a.x = b
f.u = k
f.s = i
b.u = a
b.w = k
i.u = k
i.s = f
assert i.u.w.w.txt == "k"