class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.v: A = None
        self.txt = txt

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

m = A("m")
i = B("i")
a = A("a")
k = A("k")
h = B("h")
b = A("b")
f = B("f")
g = A("g")
d = A("d")
n = A("n")

m.t = k
m.v = g
i.r = f
a.t = d
a.v = d
k.t = d
k.v = m
h.r = f
b.t = n
b.v = g
f.r = i
g.t = n
g.v = m
d.t = g
d.v = b
n.t = b
n.v = a
assert h.r.r.r.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.v: A = None
        self.txt = txt

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

m = A("m")
i = B("i")
a = A("a")
k = A("k")
h = B("h")
b = A("b")
f = B("f")
g = A("g")
d = A("d")
n = A("n")

m.t = k
m.v = g
i.r = f
a.t = d
a.v = d
k.t = d
k.v = m
h.r = f
b.t = n
b.v = g
f.r = i
g.t = n
g.v = m
d.t = g
d.v = b
n.t = b
n.v = a
assert h.r.r.r.r.r.r.r.r.r.r.txt == "i"