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

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

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

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

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

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

c.w = h
c.r = j
g.z = j
g.s = j
h.w = l
h.r = g
j.z = g
j.s = g
n.z = j
n.s = f
l.w = h
l.r = j
f.z = g
f.s = g
e.z = f
e.s = j
assert h.r.z.s.txt == "g"