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

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

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

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

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

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

k.r = h
k.t = b
l.z = m
l.t = g
m.r = n
m.t = b
n.r = f
n.t = l
h.r = n
h.t = l
f.r = k
f.t = i
b.z = n
b.t = f
g.r = h
g.t = b
i.z = h
i.t = g
assert l.z.r.t.z.r.txt == "n"