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

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

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

class D:
    def __init__(self, txt: str):
        self.q: H = None
        self.o: G = None
        self.z: A = None
        self.t: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.p: D = None
        self.o: B = None
        self.w: D = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.v: H = None
        self.o: D = None
        self.s: F = None
        self.p: A = None
        self.y: D = None
        self.w: E = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

d = A("d")
m = B("m")
k = C("k")
h = D("h")
i = E("i")
g = F("g")
f = G("f")
a = H("a")
c = B("c")

d.x = i
m.u = c
m.r = c
k.s = i
k.q = g
h.q = a
h.o = f
h.z = d
h.t = d
i.u = c
g.p = h
g.w = h
g.o = c
f.v = a
f.o = h
f.y = h
f.s = g
f.p = d
f.w = i
a.q = i
c.u = m
c.r = m
assert a.q.u.r.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: H = None
        self.o: G = None
        self.z: A = None
        self.t: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.p: D = None
        self.o: B = None
        self.w: D = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.v: H = None
        self.o: D = None
        self.s: F = None
        self.p: A = None
        self.y: D = None
        self.w: E = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

d = A("d")
m = B("m")
k = C("k")
h = D("h")
i = E("i")
g = F("g")
f = G("f")
a = H("a")
c = B("c")

d.x = i
m.u = c
m.r = c
k.s = i
k.q = g
h.q = a
h.o = f
h.z = d
h.t = d
i.u = c
g.p = h
g.w = h
g.o = c
f.v = a
f.o = h
f.y = h
f.s = g
f.p = d
f.w = i
a.q = i
c.u = m
c.r = m
assert a.q.u.r.u.r.txt == "m"