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

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

b = A("b")
c = B("c")
a = A("a")
f = A("f")
i = B("i")
j = B("j")
h = B("h")
k = B("k")
g = B("g")

b.v = h
c.p = f
c.s = i
a.v = i
f.v = j
i.p = a
i.s = h
j.p = f
j.s = h
h.p = f
h.s = g
k.p = f
k.s = i
g.p = a
g.s = h
assert g.s.p.v.s.p.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

b = A("b")
c = B("c")
a = A("a")
f = A("f")
i = B("i")
j = B("j")
h = B("h")
k = B("k")
g = B("g")

b.v = h
c.p = f
c.s = i
a.v = i
f.v = j
i.p = a
i.s = h
j.p = f
j.s = h
h.p = f
h.s = g
k.p = f
k.s = i
g.p = a
g.s = h
assert g.s.p.v.s.p.v.p.txt == "f"