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

class B:
    def __init__(self, txt: str):
        self.s: 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.t: B = None
        self.txt = txt

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

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

n.o = h
n.y = g
n.v = g
h.s = n
c.p = n
d.t = h
g.y = i
g.w = i
g.t = c
a.t = h
i.o = h
i.y = g
i.v = g
assert n.o.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: E = None
        self.v: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: 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.t: B = None
        self.txt = txt

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

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

n.o = h
n.y = g
n.v = g
h.s = n
c.p = n
d.t = h
g.y = i
g.w = i
g.t = c
a.t = h
i.o = h
i.y = g
i.v = g
assert n.o.s.y.txt == "g"