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

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

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

i = A("i")
j = B("j")
m = C("m")
h = C("h")
l = A("l")
d = C("d")
g = C("g")

i.u = l
i.r = j
j.y = i
m.t = j
m.q = i
m.u = d
h.t = j
h.q = i
h.u = m
l.u = i
l.r = j
d.t = j
d.q = i
d.u = g
g.t = j
g.q = l
g.u = h
assert m.q.u.u.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.r: B = None
        self.txt = txt

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

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

i = A("i")
j = B("j")
m = C("m")
h = C("h")
l = A("l")
d = C("d")
g = C("g")

i.u = l
i.r = j
j.y = i
m.t = j
m.q = i
m.u = d
h.t = j
h.q = i
h.u = m
l.u = i
l.r = j
d.t = j
d.q = i
d.u = g
g.t = j
g.q = l
g.u = h
assert m.q.u.u.u.r.txt == "j"