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.r: A = None
        self.txt = txt

l = A("l")
e = B("e")
h = A("h")
a = B("a")

l.t = h
l.q = h
e.r = l
h.t = l
h.q = l
a.r = h
assert e.r.q.t.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.r: A = None
        self.txt = txt

l = A("l")
e = B("e")
h = A("h")
a = B("a")

l.t = h
l.q = h
e.r = l
h.t = l
h.q = l
a.r = h
assert e.r.q.t.txt == "l"