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

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

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

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

g = A("g")
j = B("j")
e = C("e")
m = D("m")
k = B("k")
l = A("l")
b = A("b")
a = B("a")
i = D("i")
c = C("c")

g.z = c
g.v = c
g.p = a
g.u = m
j.y = b
e.r = g
e.v = g
m.r = i
m.w = b
k.y = g
l.z = e
l.v = e
l.p = a
l.u = m
b.z = c
b.v = c
b.p = k
b.u = m
a.y = l
i.r = m
i.w = b
c.r = g
c.v = l
assert m.r.r.w.u.r.w.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: C = None
        self.p: B = None
        self.u: D = None
        self.txt = txt

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

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

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

g = A("g")
j = B("j")
e = C("e")
m = D("m")
k = B("k")
l = A("l")
b = A("b")
a = B("a")
i = D("i")
c = C("c")

g.z = c
g.v = c
g.p = a
g.u = m
j.y = b
e.r = g
e.v = g
m.r = i
m.w = b
k.y = g
l.z = e
l.v = e
l.p = a
l.u = m
b.z = c
b.v = c
b.p = k
b.u = m
a.y = l
i.r = m
i.w = b
c.r = g
c.v = l
assert m.r.r.w.u.r.w.p.y.txt == "g"