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

d = A("d")
g = B("g")
b = A("b")
j = B("j")
k = B("k")
m = A("m")
c = B("c")

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

d = A("d")
g = B("g")
b = A("b")
j = B("j")
k = B("k")
m = A("m")
c = B("c")

d.v = c
g.p = c
b.v = g
j.p = c
k.p = c
m.v = j
c.p = g
assert d.v.p.p.txt == "c"