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

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

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

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

h = A("h")
c = B("c")
d = C("d")
j = D("j")
a = C("a")
g = D("g")
f = A("f")
n = A("n")

h.y = c
h.s = g
h.p = n
c.w = j
d.v = g
d.w = c
j.q = c
j.y = a
j.r = a
a.v = g
a.w = c
g.q = c
g.y = a
g.r = a
f.y = c
f.s = g
f.p = h
n.y = c
n.s = j
n.p = f
assert g.q.w.q.w.r.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: D = None
        self.p: A = None
        self.txt = txt

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

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

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

h = A("h")
c = B("c")
d = C("d")
j = D("j")
a = C("a")
g = D("g")
f = A("f")
n = A("n")

h.y = c
h.s = g
h.p = n
c.w = j
d.v = g
d.w = c
j.q = c
j.y = a
j.r = a
a.v = g
a.w = c
g.q = c
g.y = a
g.r = a
f.y = c
f.s = g
f.p = h
n.y = c
n.s = j
n.p = f
assert g.q.w.q.w.r.v.y.v.txt == "g"