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

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

e = A("e")
b = B("b")
l = A("l")
i = B("i")
n = B("n")
d = A("d")

e.y = d
e.q = l
b.t = n
l.y = d
l.q = e
i.t = n
n.t = b
d.y = e
d.q = e
assert d.q.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: A = None
        self.txt = txt

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

e = A("e")
b = B("b")
l = A("l")
i = B("i")
n = B("n")
d = A("d")

e.y = d
e.q = l
b.t = n
l.y = d
l.q = e
i.t = n
n.t = b
d.y = e
d.q = e
assert d.q.q.y.txt == "d"