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

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

i = A("i")
j = B("j")
g = A("g")
b = B("b")
c = A("c")
m = A("m")
a = A("a")
e = B("e")
f = A("f")
l = B("l")

i.r = f
i.u = j
j.q = f
j.u = e
g.r = m
g.u = j
b.q = f
b.u = l
c.r = m
c.u = b
m.r = a
m.u = j
a.r = c
a.u = e
e.q = f
e.u = l
f.r = c
f.u = l
l.q = g
l.u = j
assert i.r.r.r.r.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: B = None
        self.txt = txt

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

i = A("i")
j = B("j")
g = A("g")
b = B("b")
c = A("c")
m = A("m")
a = A("a")
e = B("e")
f = A("f")
l = B("l")

i.r = f
i.u = j
j.q = f
j.u = e
g.r = m
g.u = j
b.q = f
b.u = l
c.r = m
c.u = b
m.r = a
m.u = j
a.r = c
a.u = e
e.q = f
e.u = l
f.r = c
f.u = l
l.q = g
l.u = j
assert i.r.r.r.r.r.u.txt == "b"