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

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

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

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

n.q = f
n.s = a
a.o = e
e.s = f
e.t = n
e.v = a
f.q = n
f.s = a
assert a.o.s.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.s: B = None
        self.txt = txt

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

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

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

n.q = f
n.s = a
a.o = e
e.s = f
e.t = n
e.v = a
f.q = n
f.s = a
assert a.o.s.q.q.txt == "f"