class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: A = None
        self.w: E = None
        self.y: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: F = None
        self.y: F = None
        self.r: D = None
        self.q: A = None
        self.z: A = None
        self.u: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.o: F = None
        self.txt = txt

h = A("h")
l = B("l")
e = C("e")
k = D("k")
c = E("c")
a = F("a")
g = D("g")
b = F("b")
d = B("d")

h.p = b
h.r = g
l.s = e
l.t = h
l.w = c
l.y = a
e.s = b
e.y = b
e.r = g
e.q = h
e.z = h
e.u = d
k.p = l
k.y = h
k.r = g
k.o = c
k.w = e
c.p = h
c.x = h
c.o = g
c.t = a
a.o = b
g.p = d
g.y = h
g.r = k
g.o = c
g.w = e
b.o = a
d.s = e
d.t = h
d.w = c
d.y = b
assert h.p.o.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: A = None
        self.w: E = None
        self.y: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: F = None
        self.y: F = None
        self.r: D = None
        self.q: A = None
        self.z: A = None
        self.u: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.o: F = None
        self.txt = txt

h = A("h")
l = B("l")
e = C("e")
k = D("k")
c = E("c")
a = F("a")
g = D("g")
b = F("b")
d = B("d")

h.p = b
h.r = g
l.s = e
l.t = h
l.w = c
l.y = a
e.s = b
e.y = b
e.r = g
e.q = h
e.z = h
e.u = d
k.p = l
k.y = h
k.r = g
k.o = c
k.w = e
c.p = h
c.x = h
c.o = g
c.t = a
a.o = b
g.p = d
g.y = h
g.r = k
g.o = c
g.w = e
b.o = a
d.s = e
d.t = h
d.w = c
d.y = b
assert h.p.o.o.o.o.o.o.o.o.txt == "b"