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

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: C = None
        self.y: D = None
        self.r: C = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
d = C("d")
f = D("f")
a = B("a")
j = C("j")
m = A("m")
c = A("c")
e = B("e")
n = B("n")

g.w = c
g.y = k
k.u = d
k.q = d
k.y = f
k.r = j
d.x = n
f.r = j
f.w = d
a.u = j
a.q = j
a.r = j
a.y = f
j.x = k
m.w = g
m.y = n
c.w = g
c.y = k
e.u = d
e.q = d
e.y = f
e.r = j
n.u = j
n.q = j
n.y = f
n.r = d
assert m.w.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: C = None
        self.y: D = None
        self.r: C = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
d = C("d")
f = D("f")
a = B("a")
j = C("j")
m = A("m")
c = A("c")
e = B("e")
n = B("n")

g.w = c
g.y = k
k.u = d
k.q = d
k.y = f
k.r = j
d.x = n
f.r = j
f.w = d
a.u = j
a.q = j
a.r = j
a.y = f
j.x = k
m.w = g
m.y = n
c.w = g
c.y = k
e.u = d
e.q = d
e.y = f
e.r = j
n.u = j
n.q = j
n.y = f
n.r = d
assert m.w.w.y.txt == "k"