class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: E = None
        self.s: B = None
        self.r: G = None
        self.v: C = None
        self.t: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

l = A("l")
n = B("n")
g = C("g")
j = D("j")
m = E("m")
i = F("i")
c = G("c")

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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: E = None
        self.s: B = None
        self.r: G = None
        self.v: C = None
        self.t: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

l = A("l")
n = B("n")
g = C("g")
j = D("j")
m = E("m")
i = F("i")
c = G("c")

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