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

class B:
    def __init__(self, txt: str):
        self.w: E = None
        self.x: A = None
        self.v: G = None
        self.p: F = None
        self.txt = txt

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.x: E = None
        self.q: E = None
        self.w: E = None
        self.p: B = None
        self.v: C = None
        self.txt = txt

k = A("k")
m = B("m")
j = C("j")
c = D("c")
g = E("g")
b = F("b")
d = G("d")
h = H("h")

k.x = d
k.u = b
m.w = g
m.x = k
m.v = d
m.p = b
j.u = c
c.p = k
c.y = h
c.w = h
g.t = c
g.v = k
g.y = d
g.o = d
g.p = m
b.q = k
d.w = g
h.x = g
h.q = g
h.w = g
h.p = m
h.v = j
assert k.u.q.u.q.u.q.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: G = None
        self.u: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: E = None
        self.x: A = None
        self.v: G = None
        self.p: F = None
        self.txt = txt

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.x: E = None
        self.q: E = None
        self.w: E = None
        self.p: B = None
        self.v: C = None
        self.txt = txt

k = A("k")
m = B("m")
j = C("j")
c = D("c")
g = E("g")
b = F("b")
d = G("d")
h = H("h")

k.x = d
k.u = b
m.w = g
m.x = k
m.v = d
m.p = b
j.u = c
c.p = k
c.y = h
c.w = h
g.t = c
g.v = k
g.y = d
g.o = d
g.p = m
b.q = k
d.w = g
h.x = g
h.q = g
h.w = g
h.p = m
h.v = j
assert k.u.q.u.q.u.q.u.q.txt == "k"