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

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

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

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

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

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

i.p = j
i.s = c
d.y = a
k.p = j
k.s = c
l.y = d
a.y = l
c.p = k
c.s = i
j.p = k
j.s = n
n.p = c
n.s = j
assert l.y.y.y.y.y.txt == "a"