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

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

h = A("h")
k = B("k")
i = A("i")
l = B("l")

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

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

h = A("h")
k = B("k")
i = A("i")
l = B("l")

h.t = i
h.q = i
k.s = h
i.t = h
i.q = h
l.s = i
assert i.q.q.t.q.txt == "i"