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

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

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

f = A("f")
j = B("j")
e = C("e")

f.w = j
j.x = e
j.u = f
j.r = f
e.p = f
e.o = f
e.x = j
assert j.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

f = A("f")
j = B("j")
e = C("e")

f.w = j
j.x = e
j.u = f
j.r = f
e.p = f
e.o = f
e.x = j
assert j.x.x.x.txt == "e"