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

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: B = None
        self.r: A = None
        self.t: B = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: B = None
        self.r: A = None
        self.t: B = None
        self.txt = txt

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

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

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