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

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

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

m = A("m")
b = B("b")
f = C("f")
k = A("k")
g = B("g")
h = C("h")

m.w = f
b.q = k
b.u = f
b.x = f
f.u = b
f.s = m
k.w = h
g.q = m
g.u = f
g.x = h
h.u = b
h.s = k
assert f.s.w.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

m = A("m")
b = B("b")
f = C("f")
k = A("k")
g = B("g")
h = C("h")

m.w = f
b.q = k
b.u = f
b.x = f
f.u = b
f.s = m
k.w = h
g.q = m
g.u = f
g.x = h
h.u = b
h.s = k
assert f.s.w.u.x.txt == "f"