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

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

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

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

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

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

g.z = h
g.t = n
h.y = e
h.w = i
n.z = h
n.t = a
a.z = i
a.t = g
e.y = h
e.w = h
i.y = h
i.w = h
assert g.z.w.y.w.w.y.txt == "e"