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

class B:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
b = C("b")
e = D("e")
c = E("c")
a = E("a")

h.v = b
h.u = b
h.w = c
h.s = g
g.o = c
b.p = h
b.u = h
b.x = e
b.r = e
e.q = h
e.p = h
e.v = h
c.q = b
c.s = a
c.r = a
a.q = b
a.s = c
a.r = c
assert g.o.s.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.u: C = None
        self.w: E = None
        self.s: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
b = C("b")
e = D("e")
c = E("c")
a = E("a")

h.v = b
h.u = b
h.w = c
h.s = g
g.o = c
b.p = h
b.u = h
b.x = e
b.r = e
e.q = h
e.p = h
e.v = h
c.q = b
c.s = a
c.r = a
a.q = b
a.s = c
a.r = c
assert g.o.s.s.r.txt == "a"