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

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

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

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

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

a.w = e
a.y = h
a.r = h
g.x = a
c.s = g
c.u = g
c.q = d
c.r = e
h.u = a
h.o = a
h.r = d
f.u = a
f.o = a
f.r = g
i.x = a
j.s = d
j.u = i
j.q = i
j.r = c
e.s = d
e.u = d
e.q = i
e.r = c
d.x = a
assert e.q.x.y.u.y.r.x.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: D = None
        self.r: D = None
        self.txt = txt

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

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

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

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

a.w = e
a.y = h
a.r = h
g.x = a
c.s = g
c.u = g
c.q = d
c.r = e
h.u = a
h.o = a
h.r = d
f.u = a
f.o = a
f.r = g
i.x = a
j.s = d
j.u = i
j.q = i
j.r = c
e.s = d
e.u = d
e.q = i
e.r = c
d.x = a
assert e.q.x.y.u.y.r.x.w.r.txt == "c"