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

b = A("b")
i = B("i")
n = B("n")
g = A("g")
c = B("c")
h = A("h")
k = B("k")
m = A("m")
d = A("d")

b.v = n
i.p = c
n.p = k
g.v = n
c.p = i
h.v = n
k.p = n
m.v = k
d.v = c
assert c.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

b = A("b")
i = B("i")
n = B("n")
g = A("g")
c = B("c")
h = A("h")
k = B("k")
m = A("m")
d = A("d")

b.v = n
i.p = c
n.p = k
g.v = n
c.p = i
h.v = n
k.p = n
m.v = k
d.v = c
assert c.p.p.p.p.txt == "c"