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

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

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

a.t = c
a.v = l
h.q = c
e.q = c
c.t = a
c.v = a
l.t = a
l.v = a
assert h.q.v.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.v: A = None
        self.txt = txt

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

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

a.t = c
a.v = l
h.q = c
e.q = c
c.t = a
c.v = a
l.t = a
l.v = a
assert h.q.v.t.v.txt == "a"