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

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

l = A("l")
e = B("e")
c = A("c")
m = B("m")
d = A("d")
n = A("n")
b = B("b")

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

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

l = A("l")
e = B("e")
c = A("c")
m = B("m")
d = A("d")
n = A("n")
b = B("b")

l.q = n
e.x = m
e.y = m
c.q = n
m.x = e
m.y = b
d.q = l
n.q = c
b.x = e
b.y = m
assert e.x.x.x.y.y.x.txt == "e"