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

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

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

n.y = h
g.y = c
m.v = d
m.s = d
m.p = d
m.y = n
m.t = g
h.q = c
c.s = m
c.u = m
d.q = c
assert d.q.u.y.y.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

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

n.y = h
g.y = c
m.v = d
m.s = d
m.p = d
m.y = n
m.t = g
h.q = c
c.s = m
c.u = m
d.q = c
assert d.q.u.y.y.q.u.txt == "m"