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

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

m = A("m")
k = B("k")
i = B("i")
d = B("d")
c = B("c")
j = A("j")
n = A("n")

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

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

m = A("m")
k = B("k")
i = B("i")
d = B("d")
c = B("c")
j = A("j")
n = A("n")

m.z = c
m.p = n
k.w = i
k.y = d
i.w = d
i.y = d
d.w = c
d.y = k
c.w = k
c.y = k
j.z = k
j.p = n
n.z = c
n.p = j
assert j.z.w.w.y.y.y.y.txt == "d"