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

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

g = A("g")
m = B("m")
c = A("c")
b = A("b")
f = A("f")
l = B("l")
h = A("h")
k = B("k")

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

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

g = A("g")
m = B("m")
c = A("c")
b = A("b")
f = A("f")
l = B("l")
h = A("h")
k = B("k")

g.y = l
g.z = l
m.w = l
c.y = k
c.z = m
b.y = l
b.z = k
f.y = l
f.z = m
l.w = m
h.y = l
h.z = k
k.w = m
assert l.w.w.w.w.w.w.w.txt == "m"