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

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

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

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

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

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

m.r = b
m.s = k
l.t = k
l.q = f
k.t = l
k.q = f
a.r = m
a.s = f
b.r = m
b.s = h
f.t = k
f.q = l
i.r = b
i.s = k
h.t = f
h.q = k
assert h.q.t.q.t.txt == "k"