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

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

g = A("g")
k = B("k")
d = B("d")
h = B("h")
n = A("n")
i = B("i")
j = B("j")
b = B("b")
l = B("l")
f = A("f")

g.s = n
g.y = h
k.w = g
k.x = f
d.w = n
d.x = n
h.w = n
h.x = g
n.s = g
n.y = k
i.w = f
i.x = f
j.w = n
j.x = n
b.w = f
b.x = n
l.w = f
l.x = f
f.s = g
f.y = j
assert b.x.y.x.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.y: B = None
        self.txt = txt

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

g = A("g")
k = B("k")
d = B("d")
h = B("h")
n = A("n")
i = B("i")
j = B("j")
b = B("b")
l = B("l")
f = A("f")

g.s = n
g.y = h
k.w = g
k.x = f
d.w = n
d.x = n
h.w = n
h.x = g
n.s = g
n.y = k
i.w = f
i.x = f
j.w = n
j.x = n
b.w = f
b.x = n
l.w = f
l.x = f
f.s = g
f.y = j
assert b.x.y.x.s.y.txt == "h"