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

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

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

i.z = f
i.s = e
g.r = m
g.t = m
h.r = f
h.t = k
a.z = k
a.s = j
j.z = g
j.s = i
l.r = h
l.t = h
f.r = k
f.t = g
e.z = h
e.s = a
m.r = h
m.t = g
k.r = g
k.t = f
assert l.t.t.t.t.t.t.r.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: A = None
        self.txt = txt

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

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

i.z = f
i.s = e
g.r = m
g.t = m
h.r = f
h.t = k
a.z = k
a.s = j
j.z = g
j.s = i
l.r = h
l.t = h
f.r = k
f.t = g
e.z = h
e.s = a
m.r = h
m.t = g
k.r = g
k.t = f
assert l.t.t.t.t.t.t.r.r.t.txt == "k"