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

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

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

i = A("i")
f = B("f")
g = C("g")
a = A("a")

i.r = a
f.w = g
g.u = a
a.r = i
assert f.w.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

i = A("i")
f = B("f")
g = C("g")
a = A("a")

i.r = a
f.w = g
g.u = a
a.r = i
assert f.w.u.r.txt == "i"