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

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

h = A("h")
m = B("m")
i = B("i")
k = A("k")
e = A("e")

h.q = e
h.t = e
m.s = i
m.v = i
i.s = m
i.v = m
k.q = e
k.t = e
e.q = k
e.t = k
assert k.q.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: A = None
        self.txt = txt

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

h = A("h")
m = B("m")
i = B("i")
k = A("k")
e = A("e")

h.q = e
h.t = e
m.s = i
m.v = i
i.s = m
i.v = m
k.q = e
k.t = e
e.q = k
e.t = k
assert k.q.t.q.txt == "e"