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

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

i = A("i")
h = B("h")
f = B("f")
d = A("d")
e = B("e")
b = A("b")
k = B("k")
a = A("a")
g = B("g")

i.v = g
h.p = k
f.p = g
d.v = g
e.p = h
b.v = g
k.p = g
a.v = f
g.p = k
assert g.p.p.p.p.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: B = None
        self.txt = txt

i = A("i")
h = B("h")
f = B("f")
d = A("d")
e = B("e")
b = A("b")
k = B("k")
a = A("a")
g = B("g")

i.v = g
h.p = k
f.p = g
d.v = g
e.p = h
b.v = g
k.p = g
a.v = f
g.p = k
assert g.p.p.p.p.p.txt == "k"