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

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

g = A("g")
c = B("c")
e = B("e")
f = B("f")
b = A("b")
l = B("l")
h = B("h")
n = A("n")
k = B("k")
j = A("j")

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

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

g = A("g")
c = B("c")
e = B("e")
f = B("f")
b = A("b")
l = B("l")
h = B("h")
n = A("n")
k = B("k")
j = A("j")

g.w = b
c.z = n
e.z = n
f.z = n
b.w = n
l.z = j
h.z = j
n.w = b
k.z = b
j.w = b
assert f.z.w.w.w.w.w.w.txt == "n"