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

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

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

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

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

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

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

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

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

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

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

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

h.u = b
n.o = b
a.q = i
a.t = c
a.w = b
c.t = n
c.r = a
g.t = m
g.v = c
g.s = a
i.o = b
b.u = h
m.q = i
m.t = c
m.w = h
assert g.t.t.t.o.u.u.u.u.txt == "b"