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

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

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

class D:
    def __init__(self, txt: str):
        self.t: F = None
        self.v: E = None
        self.y: A = None
        self.z: F = None
        self.txt = txt

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

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

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

c.p = h
c.o = k
c.w = g
m.p = g
m.r = i
k.p = h
k.x = c
k.o = m
h.t = i
h.z = i
h.v = b
h.y = c
b.u = m
b.z = k
b.w = c
i.p = h
i.u = h
g.u = m
g.z = k
g.w = c
assert k.x.p.v.z.o.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.o: C = None
        self.w: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: F = None
        self.v: E = None
        self.y: A = None
        self.z: F = None
        self.txt = txt

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

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

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

c.p = h
c.o = k
c.w = g
m.p = g
m.r = i
k.p = h
k.x = c
k.o = m
h.t = i
h.z = i
h.v = b
h.y = c
b.u = m
b.z = k
b.w = c
i.p = h
i.u = h
g.u = m
g.z = k
g.w = c
assert k.x.p.v.z.o.p.z.txt == "k"