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

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

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

k = A("k")
b = B("b")
m = C("m")
j = B("j")
a = B("a")
h = B("h")
l = A("l")
e = B("e")
g = A("g")

k.x = g
k.q = b
b.s = l
b.x = l
m.x = e
j.s = k
j.x = g
a.s = l
a.x = l
h.s = g
h.x = k
l.x = g
l.q = h
e.s = l
e.x = g
g.x = k
g.q = b
assert h.s.x.q.s.x.q.s.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: B = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
m = C("m")
j = B("j")
a = B("a")
h = B("h")
l = A("l")
e = B("e")
g = A("g")

k.x = g
k.q = b
b.s = l
b.x = l
m.x = e
j.s = k
j.x = g
a.s = l
a.x = l
h.s = g
h.x = k
l.x = g
l.q = h
e.s = l
e.x = g
g.x = k
g.q = b
assert h.s.x.q.s.x.q.s.q.s.txt == "g"