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

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

l = A("l")
i = B("i")
a = B("a")
f = A("f")
d = B("d")
j = B("j")
g = A("g")
e = B("e")

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

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

l = A("l")
i = B("i")
a = B("a")
f = A("f")
d = B("d")
j = B("j")
g = A("g")
e = B("e")

l.p = g
i.u = f
a.u = f
f.p = g
d.u = g
j.u = g
g.p = f
e.u = g
assert e.u.p.p.txt == "g"