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

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

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

e = A("e")
k = B("k")
f = C("f")
g = A("g")

e.u = f
e.t = k
k.u = f
f.t = e
f.w = k
g.u = f
g.t = k
assert g.t.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.t: B = None
        self.txt = txt

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

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

e = A("e")
k = B("k")
f = C("f")
g = A("g")

e.u = f
e.t = k
k.u = f
f.t = e
f.w = k
g.u = f
g.t = k
assert g.t.u.w.txt == "k"