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

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.q: E = None
        self.p: E = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.q: E = None
        self.p: E = None
        self.txt = txt

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

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

c.y = f
c.r = b
c.q = b
c.x = g
c.s = a
n.q = j
n.v = c
n.w = b
b.o = c
b.r = g
g.t = a
g.q = a
g.p = d
d.w = c
f.q = j
f.v = c
f.w = b
a.w = c
j.o = c
j.r = g
assert g.p.w.s.w.r.r.txt == "g"