class A:
    def __init__(self, txt: str):
        self.o: B = 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: B = None
        self.txt = txt

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

k.o = f
f.w = g
g.u = f
assert k.o.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = 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: B = None
        self.txt = txt

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

k.o = f
f.w = g
g.u = f
assert k.o.w.u.txt == "f"