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

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

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

d.s = l
g.p = n
g.v = l
e.p = l
e.v = k
j.s = k
k.s = l
l.s = j
n.s = k
assert e.p.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

d.s = l
g.p = n
g.v = l
e.p = l
e.v = k
j.s = k
k.s = l
l.s = j
n.s = k
assert e.p.s.s.s.s.s.s.txt == "l"