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

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

e = A("e")
l = B("l")
g = A("g")
j = A("j")
a = A("a")
n = A("n")

e.q = l
l.p = g
g.q = l
j.q = l
a.q = l
n.q = l
assert l.p.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

e = A("e")
l = B("l")
g = A("g")
j = A("j")
a = A("a")
n = A("n")

e.q = l
l.p = g
g.q = l
j.q = l
a.q = l
n.q = l
assert l.p.q.p.txt == "g"