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

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

i = A("i")
b = B("b")
h = A("h")

i.p = h
i.v = h
b.x = h
h.p = i
h.v = i
assert i.p.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.v: A = None
        self.txt = txt

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

i = A("i")
b = B("b")
h = A("h")

i.p = h
i.v = h
b.x = h
h.p = i
h.v = i
assert i.p.v.v.txt == "h"