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

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

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

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

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

g.w = a
g.q = h
g.r = h
g.x = j
i.z = b
n.x = j
n.w = i
n.p = c
b.t = n
b.o = a
b.w = c
d.z = j
c.t = n
c.o = g
c.w = j
h.w = g
h.q = a
h.r = a
h.x = j
k.z = j
a.w = h
a.q = g
a.r = g
a.x = b
j.t = n
j.o = g
j.w = b
assert g.r.r.x.t.x.o.x.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.q: A = None
        self.r: A = None
        self.x: D = None
        self.txt = txt

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

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

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

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

g.w = a
g.q = h
g.r = h
g.x = j
i.z = b
n.x = j
n.w = i
n.p = c
b.t = n
b.o = a
b.w = c
d.z = j
c.t = n
c.o = g
c.w = j
h.w = g
h.q = a
h.r = a
h.x = j
k.z = j
a.w = h
a.q = g
a.r = g
a.x = b
j.t = n
j.o = g
j.w = b
assert g.r.r.x.t.x.o.x.w.t.w.txt == "i"