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

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

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

f = A("f")
n = B("n")
h = C("h")

f.u = n
f.s = h
n.t = h
h.q = n
assert n.t.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: C = None
        self.txt = txt

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

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

f = A("f")
n = B("n")
h = C("h")

f.u = n
f.s = h
n.t = h
h.q = n
assert n.t.q.t.txt == "h"