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

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

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

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

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

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

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

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

f.x = e
f.s = j
f.p = j
j.x = e
j.s = b
b.r = j
b.u = e
e.x = f
e.s = j
e.p = j
assert b.r.s.r.x.txt == "e"