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

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

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

d = A("d")
m = B("m")
a = C("a")
e = A("e")
f = B("f")

d.w = m
d.x = m
m.x = e
m.q = f
a.s = f
a.y = f
a.z = e
e.w = m
e.x = f
f.x = d
f.q = m
assert e.x.x.w.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: B = None
        self.txt = txt

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

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

d = A("d")
m = B("m")
a = C("a")
e = A("e")
f = B("f")

d.w = m
d.x = m
m.x = e
m.q = f
a.s = f
a.y = f
a.z = e
e.w = m
e.x = f
f.x = d
f.q = m
assert e.x.x.w.x.w.txt == "m"