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

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: C = None
        self.y: E = None
        self.txt = txt

h = A("h")
i = B("i")
g = C("g")
f = D("f")
c = E("c")
j = E("j")
n = E("n")

h.o = g
h.s = f
i.u = g
i.v = f
i.o = f
g.x = h
g.s = h
g.z = n
g.u = n
g.q = f
f.p = g
c.o = h
c.t = g
c.y = n
j.o = h
j.t = g
j.y = c
n.o = h
n.t = g
n.y = j
assert c.y.o.o.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: C = None
        self.y: E = None
        self.txt = txt

h = A("h")
i = B("i")
g = C("g")
f = D("f")
c = E("c")
j = E("j")
n = E("n")

h.o = g
h.s = f
i.u = g
i.v = f
i.o = f
g.x = h
g.s = h
g.z = n
g.u = n
g.q = f
f.p = g
c.o = h
c.t = g
c.y = n
j.o = h
j.t = g
j.y = c
n.o = h
n.t = g
n.y = j
assert c.y.o.o.q.p.txt == "g"