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

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

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

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

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

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

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

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

h.v = k
h.s = n
j.q = h
j.s = e
j.r = m
e.x = j
e.q = j
n.x = j
n.q = j
a.x = j
a.q = j
i.x = j
i.q = j
m.x = j
m.q = j
k.v = h
k.s = m
assert k.v.v.v.s.x.q.s.q.txt == "j"