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

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

f = A("f")
j = B("j")
l = B("l")
n = A("n")
h = A("h")
e = A("e")
g = B("g")
i = B("i")

f.y = j
f.w = i
j.z = f
l.z = h
n.y = i
n.w = g
h.y = i
h.w = g
e.y = j
e.w = i
g.z = f
i.z = e
assert l.z.w.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: B = None
        self.txt = txt

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

f = A("f")
j = B("j")
l = B("l")
n = A("n")
h = A("h")
e = A("e")
g = B("g")
i = B("i")

f.y = j
f.w = i
j.z = f
l.z = h
n.y = i
n.w = g
h.y = i
h.w = g
e.y = j
e.w = i
g.z = f
i.z = e
assert l.z.w.z.y.txt == "j"