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

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

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

f = A("f")
n = B("n")
m = C("m")
b = A("b")
i = B("i")

f.q = m
f.v = n
f.x = i
n.r = m
n.x = i
n.s = i
m.z = i
b.q = m
b.v = i
b.x = n
i.r = m
i.x = n
i.s = n
assert n.s.r.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: B = None
        self.x: B = None
        self.txt = txt

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

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

f = A("f")
n = B("n")
m = C("m")
b = A("b")
i = B("i")

f.q = m
f.v = n
f.x = i
n.r = m
n.x = i
n.s = i
m.z = i
b.q = m
b.v = i
b.x = n
i.r = m
i.x = n
i.s = n
assert n.s.r.z.r.txt == "m"