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

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

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

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

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

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

b.u = f
n.q = b
n.v = b
n.w = e
i.y = e
i.r = e
i.w = m
e.r = b
e.v = h
e.o = i
h.p = e
a.y = e
a.r = e
a.w = m
m.p = e
c.y = e
c.r = e
c.w = h
f.y = e
f.r = e
f.w = m
g.q = b
g.v = b
g.w = e
assert i.y.v.p.v.p.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

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

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

b.u = f
n.q = b
n.v = b
n.w = e
i.y = e
i.r = e
i.w = m
e.r = b
e.v = h
e.o = i
h.p = e
a.y = e
a.r = e
a.w = m
m.p = e
c.y = e
c.r = e
c.w = h
f.y = e
f.r = e
f.w = m
g.q = b
g.v = b
g.w = e
assert i.y.v.p.v.p.r.u.txt == "f"