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

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

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

f = A("f")
d = B("d")
k = C("k")
h = B("h")
a = C("a")

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

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

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

f = A("f")
d = B("d")
k = C("k")
h = B("h")
a = C("a")

f.u = h
d.s = f
d.q = h
k.o = f
h.s = f
h.q = d
a.o = f
assert f.u.q.s.txt == "f"