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

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

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

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

n = A("n")
d = B("d")
k = C("k")
g = D("g")
m = B("m")
b = A("b")
c = D("c")
a = D("a")
h = B("h")
i = C("i")

n.s = m
n.r = b
n.w = d
d.q = c
d.z = c
d.p = n
d.v = b
k.y = n
g.p = c
g.w = b
m.q = g
m.p = b
m.v = b
m.z = c
b.s = d
b.w = d
b.r = n
c.p = a
c.w = b
a.p = g
a.w = n
h.q = g
h.p = b
h.z = a
h.v = n
i.y = b
assert c.p.p.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: A = None
        self.w: B = None
        self.txt = txt

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

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

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

n = A("n")
d = B("d")
k = C("k")
g = D("g")
m = B("m")
b = A("b")
c = D("c")
a = D("a")
h = B("h")
i = C("i")

n.s = m
n.r = b
n.w = d
d.q = c
d.z = c
d.p = n
d.v = b
k.y = n
g.p = c
g.w = b
m.q = g
m.p = b
m.v = b
m.z = c
b.s = d
b.w = d
b.r = n
c.p = a
c.w = b
a.p = g
a.w = n
h.q = g
h.p = b
h.z = a
h.v = n
i.y = b
assert c.p.p.p.w.txt == "b"