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

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

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

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

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

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

e.s = n
e.w = n
h.y = i
g.s = n
g.w = i
j.y = i
n.y = h
i.y = h
d.s = h
d.w = h
c.s = n
c.w = j
assert n.y.y.y.y.y.y.y.y.txt == "i"