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

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

b = A("b")
h = B("h")
j = B("j")
e = A("e")

b.p = j
b.v = h
h.o = e
j.o = e
e.p = j
e.v = h
assert e.v.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: B = None
        self.txt = txt

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

b = A("b")
h = B("h")
j = B("j")
e = A("e")

b.p = j
b.v = h
h.o = e
j.o = e
e.p = j
e.v = h
assert e.v.o.p.txt == "j"