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

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

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

i = A("i")
g = B("g")
m = C("m")
n = B("n")
h = B("h")
k = C("k")
j = A("j")
f = B("f")
e = A("e")

i.x = m
g.u = h
g.v = h
g.s = m
m.q = n
m.u = k
n.u = g
n.v = g
n.s = m
h.u = n
h.v = n
h.s = k
k.q = n
k.u = m
j.x = m
f.u = h
f.v = h
f.s = m
e.x = k
assert e.x.u.u.u.q.u.s.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

i = A("i")
g = B("g")
m = C("m")
n = B("n")
h = B("h")
k = C("k")
j = A("j")
f = B("f")
e = A("e")

i.x = m
g.u = h
g.v = h
g.s = m
m.q = n
m.u = k
n.u = g
n.v = g
n.s = m
h.u = n
h.v = n
h.s = k
k.q = n
k.u = m
j.x = m
f.u = h
f.v = h
f.s = m
e.x = k
assert e.x.u.u.u.q.u.s.q.s.txt == "m"