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

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

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

f = A("f")
a = B("a")
l = C("l")
e = A("e")
n = C("n")

f.s = e
f.o = l
f.r = a
a.x = n
l.x = n
l.p = n
e.s = f
e.o = n
e.r = a
n.x = l
n.p = l
assert a.x.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.o: C = None
        self.r: B = None
        self.txt = txt

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

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

f = A("f")
a = B("a")
l = C("l")
e = A("e")
n = C("n")

f.s = e
f.o = l
f.r = a
a.x = n
l.x = n
l.p = n
e.s = f
e.o = n
e.r = a
n.x = l
n.p = l
assert a.x.p.x.txt == "n"