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

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

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

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

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

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

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

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

m.s = g
m.x = n
m.r = e
a.v = g
k.r = m
k.v = f
k.q = d
f.r = g
f.v = k
f.q = d
n.v = g
d.r = e
d.v = k
d.q = k
g.s = m
g.r = m
g.x = a
e.s = g
e.r = g
e.x = a
assert g.s.s.r.r.s.x.txt == "a"