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

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

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

class D:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: D = None
        self.y: F = None
        self.p: A = None
        self.z: C = None
        self.r: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.q: C = None
        self.t: D = None
        self.p: D = None
        self.txt = txt

g = A("g")
h = B("h")
k = C("k")
i = D("i")
d = E("d")
n = F("n")
j = C("j")

g.x = k
g.r = k
h.t = k
h.y = i
h.q = d
k.r = g
i.v = h
i.q = h
d.u = j
d.x = i
d.r = i
d.y = n
d.p = g
d.z = k
n.q = j
n.t = i
n.p = i
j.r = g
assert n.q.r.x.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.r: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: D = None
        self.y: F = None
        self.p: A = None
        self.z: C = None
        self.r: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.q: C = None
        self.t: D = None
        self.p: D = None
        self.txt = txt

g = A("g")
h = B("h")
k = C("k")
i = D("i")
d = E("d")
n = F("n")
j = C("j")

g.x = k
g.r = k
h.t = k
h.y = i
h.q = d
k.r = g
i.v = h
i.q = h
d.u = j
d.x = i
d.r = i
d.y = n
d.p = g
d.z = k
n.q = j
n.t = i
n.p = i
j.r = g
assert n.q.r.x.r.x.txt == "k"