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

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

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

f = A("f")
b = B("b")
n = C("n")
k = B("k")

f.s = k
b.u = k
b.o = n
b.q = f
n.u = k
k.u = b
k.o = n
k.q = f
assert k.o.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

f = A("f")
b = B("b")
n = C("n")
k = B("k")

f.s = k
b.u = k
b.o = n
b.q = f
n.u = k
k.u = b
k.o = n
k.q = f
assert k.o.u.q.txt == "f"