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

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

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

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

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

g = A("g")
n = B("n")
m = C("m")
h = D("h")
i = E("i")

g.p = n
g.v = i
g.u = i
n.q = m
n.w = m
m.u = i
m.x = n
m.t = g
h.u = i
h.s = m
h.w = n
i.y = m
assert g.u.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: E = None
        self.u: E = None
        self.txt = txt

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

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

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

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

g = A("g")
n = B("n")
m = C("m")
h = D("h")
i = E("i")

g.p = n
g.v = i
g.u = i
n.q = m
n.w = m
m.u = i
m.x = n
m.t = g
h.u = i
h.s = m
h.w = n
i.y = m
assert g.u.y.t.txt == "g"