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

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

i = A("i")
h = B("h")
k = A("k")
m = A("m")
j = B("j")
d = A("d")
e = B("e")
a = A("a")
l = B("l")
g = A("g")

i.x = g
i.u = a
h.r = i
h.s = e
k.x = i
k.u = g
m.x = g
m.u = a
j.r = g
j.s = e
d.x = a
d.u = g
e.r = m
e.s = l
a.x = k
a.u = i
l.r = g
l.s = e
g.x = i
g.u = m
assert i.u.u.u.x.u.x.x.x.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.u: A = None
        self.txt = txt

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

i = A("i")
h = B("h")
k = A("k")
m = A("m")
j = B("j")
d = A("d")
e = B("e")
a = A("a")
l = B("l")
g = A("g")

i.x = g
i.u = a
h.r = i
h.s = e
k.x = i
k.u = g
m.x = g
m.u = a
j.r = g
j.s = e
d.x = a
d.u = g
e.r = m
e.s = l
a.x = k
a.u = i
l.r = g
l.s = e
g.x = i
g.u = m
assert i.u.u.u.x.u.x.x.x.u.u.txt == "i"