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

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

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

m = A("m")
b = B("b")
h = C("h")
j = B("j")
i = A("i")
g = B("g")
a = A("a")
c = A("c")
n = C("n")

m.q = g
m.t = n
m.x = b
b.s = g
h.x = b
h.u = m
j.s = g
i.q = j
i.x = j
i.t = n
g.s = b
a.q = b
a.t = h
a.x = j
c.q = j
c.t = n
c.x = g
n.x = j
n.u = m
assert j.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.t: C = None
        self.x: B = None
        self.txt = txt

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

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

m = A("m")
b = B("b")
h = C("h")
j = B("j")
i = A("i")
g = B("g")
a = A("a")
c = A("c")
n = C("n")

m.q = g
m.t = n
m.x = b
b.s = g
h.x = b
h.u = m
j.s = g
i.q = j
i.x = j
i.t = n
g.s = b
a.q = b
a.t = h
a.x = j
c.q = j
c.t = n
c.x = g
n.x = j
n.u = m
assert j.s.s.s.s.s.s.txt == "b"