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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.v: C = None
        self.t: A = None
        self.o: A = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
d = C("d")
b = D("b")
j = E("j")
c = C("c")
a = D("a")
i = B("i")

h.y = i
h.z = a
g.p = h
g.t = h
g.o = h
g.v = d
d.p = h
b.o = j
b.w = g
j.q = g
j.u = h
c.p = h
a.o = j
a.w = g
i.p = h
i.t = h
i.o = h
i.v = c
assert g.v.p.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.v: C = None
        self.t: A = None
        self.o: A = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
d = C("d")
b = D("b")
j = E("j")
c = C("c")
a = D("a")
i = B("i")

h.y = i
h.z = a
g.p = h
g.t = h
g.o = h
g.v = d
d.p = h
b.o = j
b.w = g
j.q = g
j.u = h
c.p = h
a.o = j
a.w = g
i.p = h
i.t = h
i.o = h
i.v = c
assert g.v.p.y.v.txt == "c"