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

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

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

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

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

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

c.p = g
c.y = m
c.x = b
b.t = d
b.p = d
b.w = c
n.x = i
d.w = g
a.u = c
a.v = d
a.o = d
a.r = m
a.y = m
m.u = c
m.v = d
m.o = d
m.r = a
m.y = a
i.t = d
i.p = d
i.w = c
g.x = i
assert i.w.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: E = None
        self.x: B = None
        self.txt = txt

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

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

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

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

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

c.p = g
c.y = m
c.x = b
b.t = d
b.p = d
b.w = c
n.x = i
d.w = g
a.u = c
a.v = d
a.o = d
a.r = m
a.y = m
m.u = c
m.v = d
m.o = d
m.r = a
m.y = a
i.t = d
i.p = d
i.w = c
g.x = i
assert i.w.x.p.txt == "d"