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

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

e = A("e")
b = B("b")
i = A("i")
d = B("d")
a = A("a")
c = A("c")

e.q = b
b.q = d
i.q = b
d.q = b
a.q = b
c.q = b
assert b.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

e = A("e")
b = B("b")
i = A("i")
d = B("d")
a = A("a")
c = A("c")

e.q = b
b.q = d
i.q = b
d.q = b
a.q = b
c.q = b
assert b.q.q.q.q.q.txt == "d"