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

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

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

class D:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

h.y = n
h.p = d
h.u = g
m.v = h
m.t = n
m.q = n
m.r = g
n.o = h
n.p = d
n.t = d
d.x = m
j.r = d
g.y = n
g.p = d
g.u = h
assert d.x.q.o.y.txt == "n"