class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: C = None
        self.v: G = None
        self.r: G = None
        self.p: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: H = None
        self.p: F = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: B = None
        self.r: C = None
        self.q: F = None
        self.x: H = None
        self.o: F = None
        self.p: D = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: C = None
        self.t: A = None
        self.s: E = None
        self.txt = txt

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

f = A("f")
h = B("h")
c = C("c")
a = D("a")
n = E("n")
d = F("d")
b = G("b")
g = H("g")
l = A("l")
e = H("e")

f.x = a
f.u = c
f.v = b
f.r = b
f.p = h
h.p = n
c.q = g
c.p = d
a.q = c
n.u = f
n.s = h
n.r = c
n.q = d
n.o = d
n.x = e
n.p = a
d.v = f
b.v = f
b.t = f
b.w = c
b.s = n
g.w = a
l.x = a
l.u = c
l.v = b
l.r = b
l.p = h
e.w = a
assert e.w.q.q.w.q.q.w.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: C = None
        self.v: G = None
        self.r: G = None
        self.p: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: H = None
        self.p: F = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: B = None
        self.r: C = None
        self.q: F = None
        self.x: H = None
        self.o: F = None
        self.p: D = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: C = None
        self.t: A = None
        self.s: E = None
        self.txt = txt

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

f = A("f")
h = B("h")
c = C("c")
a = D("a")
n = E("n")
d = F("d")
b = G("b")
g = H("g")
l = A("l")
e = H("e")

f.x = a
f.u = c
f.v = b
f.r = b
f.p = h
h.p = n
c.q = g
c.p = d
a.q = c
n.u = f
n.s = h
n.r = c
n.q = d
n.o = d
n.x = e
n.p = a
d.v = f
b.v = f
b.t = f
b.w = c
b.s = n
g.w = a
l.x = a
l.u = c
l.v = b
l.r = b
l.p = h
e.w = a
assert e.w.q.q.w.q.q.w.q.q.txt == "g"