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

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

a = A("a")
i = B("i")
k = A("k")
n = A("n")
j = B("j")
g = A("g")
c = A("c")
b = A("b")
l = B("l")
d = A("d")

a.w = j
i.y = l
i.p = n
k.w = j
n.w = l
j.y = l
j.p = k
g.w = j
c.w = l
b.w = l
l.y = i
l.p = a
d.w = l
assert j.y.y.y.y.y.p.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

a = A("a")
i = B("i")
k = A("k")
n = A("n")
j = B("j")
g = A("g")
c = A("c")
b = A("b")
l = B("l")
d = A("d")

a.w = j
i.y = l
i.p = n
k.w = j
n.w = l
j.y = l
j.p = k
g.w = j
c.w = l
b.w = l
l.y = i
l.p = a
d.w = l
assert j.y.y.y.y.y.p.w.y.txt == "l"