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

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

k = A("k")
j = B("j")
m = B("m")
n = B("n")

k.w = n
j.y = n
j.p = m
m.y = j
m.p = j
n.y = m
n.p = j
assert k.w.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

k = A("k")
j = B("j")
m = B("m")
n = B("n")

k.w = n
j.y = n
j.p = m
m.y = j
m.p = j
n.y = m
n.p = j
assert k.w.p.p.txt == "m"