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

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

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

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

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

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

k = A("k")
n = B("n")
g = C("g")
c = D("c")
m = E("m")
i = F("i")

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

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

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

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

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

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

k = A("k")
n = B("n")
g = C("g")
c = D("c")
m = E("m")
i = F("i")

k.r = i
n.q = i
n.v = k
n.p = k
n.x = m
n.s = m
g.w = m
g.q = m
g.u = k
c.q = n
c.t = n
c.z = k
c.o = g
m.q = k
m.v = n
i.o = n
i.x = m
i.w = k
i.z = k
i.p = c
assert g.w.v.s.q.r.txt == "i"