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

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

h = A("h")
d = B("d")
c = B("c")
k = B("k")

h.v = c
h.p = d
d.y = c
c.y = d
k.y = c
assert c.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.p: B = None
        self.txt = txt

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

h = A("h")
d = B("d")
c = B("c")
k = B("k")

h.v = c
h.p = d
d.y = c
c.y = d
k.y = c
assert c.y.y.y.y.txt == "c"