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

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

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

f = A("f")
m = B("m")
b = C("b")
g = A("g")
n = C("n")
c = B("c")

f.s = n
f.w = g
f.q = g
m.y = b
m.z = f
m.r = c
b.y = n
b.s = g
g.s = n
g.w = f
g.q = f
n.y = b
n.s = f
c.y = b
c.z = f
c.r = m
assert m.z.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.w: A = None
        self.q: A = None
        self.txt = txt

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

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

f = A("f")
m = B("m")
b = C("b")
g = A("g")
n = C("n")
c = B("c")

f.s = n
f.w = g
f.q = g
m.y = b
m.z = f
m.r = c
b.y = n
b.s = g
g.s = n
g.w = f
g.q = f
n.y = b
n.s = f
c.y = b
c.z = f
c.r = m
assert m.z.s.s.txt == "f"