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

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

i = A("i")
e = B("e")
d = A("d")
a = A("a")
j = B("j")
n = A("n")
g = B("g")
h = A("h")

i.z = j
i.w = a
e.s = h
e.o = j
d.z = g
d.w = i
a.z = j
a.w = h
j.s = n
j.o = g
n.z = j
n.w = i
g.s = a
g.o = j
h.z = j
h.w = a
assert i.z.s.z.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: A = None
        self.txt = txt

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

i = A("i")
e = B("e")
d = A("d")
a = A("a")
j = B("j")
n = A("n")
g = B("g")
h = A("h")

i.z = j
i.w = a
e.s = h
e.o = j
d.z = g
d.w = i
a.z = j
a.w = h
j.s = n
j.o = g
n.z = j
n.w = i
g.s = a
g.o = j
h.z = j
h.w = a
assert i.z.s.z.s.w.txt == "i"