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

class B:
    def __init__(self, txt: str):
        self.v: E = None
        self.u: A = None
        self.o: C = None
        self.y: A = None
        self.txt = txt

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

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

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

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

n = A("n")
c = B("c")
h = C("h")
f = D("f")
g = E("g")
e = F("e")
b = D("b")

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

class B:
    def __init__(self, txt: str):
        self.v: E = None
        self.u: A = None
        self.o: C = None
        self.y: A = None
        self.txt = txt

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

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

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

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

n = A("n")
c = B("c")
h = C("h")
f = D("f")
g = E("g")
e = F("e")
b = D("b")

n.z = h
n.w = h
n.r = h
n.y = b
c.v = g
c.u = n
c.y = n
c.o = h
h.z = g
h.p = g
f.r = n
f.x = n
f.u = h
f.t = c
f.o = b
g.p = h
e.p = h
b.r = n
b.x = n
b.u = h
b.t = c
b.o = f
assert h.z.p.z.p.p.p.z.txt == "g"