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

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

k = A("k")
d = B("d")
c = B("c")
f = A("f")
h = B("h")
l = A("l")
j = A("j")
e = B("e")

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

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

k = A("k")
d = B("d")
c = B("c")
f = A("f")
h = B("h")
l = A("l")
j = A("j")
e = B("e")

k.s = j
k.v = j
d.y = c
d.p = e
c.y = d
c.p = d
f.s = k
f.v = l
h.y = c
h.p = d
l.s = k
l.v = k
j.s = f
j.v = l
e.y = c
e.p = h
assert h.p.y.p.p.p.txt == "h"