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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: B = None
        self.y: H = None
        self.txt = txt

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

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

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

class G:
    def __init__(self, txt: str):
        self.o: A = None
        self.z: D = None
        self.y: E = None
        self.r: F = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.x: F = None
        self.q: B = None
        self.w: B = None
        self.txt = txt

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

k.x = e
k.y = g
k.q = g
k.r = d
e.u = g
e.p = g
g.q = k
g.x = e
g.y = c
d.r = g
d.w = m
f.q = g
m.w = f
h.o = k
h.z = d
h.y = f
h.r = m
c.x = m
c.q = e
c.w = e
assert c.q.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.y: C = None
        self.r: D = None
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: B = None
        self.y: H = None
        self.txt = txt

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

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

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

class G:
    def __init__(self, txt: str):
        self.o: A = None
        self.z: D = None
        self.y: E = None
        self.r: F = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.x: F = None
        self.q: B = None
        self.w: B = None
        self.txt = txt

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

k.x = e
k.y = g
k.q = g
k.r = d
e.u = g
e.p = g
g.q = k
g.x = e
g.y = c
d.r = g
d.w = m
f.q = g
m.w = f
h.o = k
h.z = d
h.y = f
h.r = m
c.x = m
c.q = e
c.w = e
assert c.q.p.q.txt == "k"