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

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

c = A("c")
b = B("b")
j = A("j")

c.w = j
c.p = j
b.y = c
j.w = c
j.p = c
assert c.p.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.p: A = None
        self.txt = txt

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

c = A("c")
b = B("b")
j = A("j")

c.w = j
c.p = j
b.y = c
j.w = c
j.p = c
assert c.p.p.w.txt == "j"