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

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

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

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

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

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

g.p = e
j.u = l
n.p = e
l.p = e
d.p = j
a.p = j
c.p = j
e.u = l
assert j.u.p.u.p.u.p.u.txt == "l"