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

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

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

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

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

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

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

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

f.y = b
f.v = e
f.z = g
c.r = f
c.x = m
n.r = m
n.q = c
n.s = e
e.r = f
e.x = m
g.r = f
g.x = f
m.y = b
m.v = c
m.z = c
k.r = m
k.x = f
b.r = f
b.q = e
b.s = c
assert m.z.x.y.s.x.z.x.txt == "m"