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

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

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

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

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

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

c.w = e
c.v = h
h.p = j
h.u = c
j.p = h
j.u = c
e.p = h
e.u = c
assert h.u.w.p.u.txt == "c"