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

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

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

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

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

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

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

n.x = k
n.r = l
n.p = c
g.r = b
g.p = m
k.s = b
k.r = c
k.x = c
k.t = i
c.z = k
l.z = e
b.w = n
m.r = i
m.p = g
i.w = n
e.s = i
e.r = c
e.x = c
e.t = b
assert c.z.t.w.x.r.z.r.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.r: E = None
        self.p: D = None
        self.txt = txt

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

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

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

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

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

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

n.x = k
n.r = l
n.p = c
g.r = b
g.p = m
k.s = b
k.r = c
k.x = c
k.t = i
c.z = k
l.z = e
b.w = n
m.r = i
m.p = g
i.w = n
e.s = i
e.r = c
e.x = c
e.t = b
assert c.z.t.w.x.r.z.r.z.t.txt == "i"