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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: E = None
        self.o: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.o: D = None
        self.v: D = None
        self.txt = txt

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

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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: E = None
        self.o: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.o: D = None
        self.v: D = None
        self.txt = txt

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

h.p = c
k.q = g
k.o = d
k.v = h
c.z = f
c.t = d
c.o = k
g.q = d
g.y = m
g.u = k
m.t = k
m.o = g
m.v = f
n.p = c
d.t = k
d.o = g
d.v = f
f.q = m
f.y = d
f.u = k
assert f.q.t.q.y.v.q.o.txt == "g"