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

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

class C:
    def __init__(self, txt: str):
        self.r: G = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: E = None
        self.q: C = None
        self.p: H = None
        self.x: G = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: D = None
        self.w: D = None
        self.txt = txt

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

g = A("g")
i = B("i")
k = C("k")
b = D("b")
j = E("j")
e = F("e")
c = G("c")
n = H("n")

g.q = n
i.z = j
k.r = c
b.s = j
b.q = k
b.p = n
b.x = c
j.v = b
j.u = i
j.z = k
e.v = k
e.t = g
c.x = k
c.y = b
c.w = b
n.q = k
assert k.r.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: H = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: G = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: E = None
        self.q: C = None
        self.p: H = None
        self.x: G = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: D = None
        self.w: D = None
        self.txt = txt

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

g = A("g")
i = B("i")
k = C("k")
b = D("b")
j = E("j")
e = F("e")
c = G("c")
n = H("n")

g.q = n
i.z = j
k.r = c
b.s = j
b.q = k
b.p = n
b.x = c
j.v = b
j.u = i
j.z = k
e.v = k
e.t = g
c.x = k
c.y = b
c.w = b
n.q = k
assert k.r.x.r.txt == "c"