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

class B:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: B = None
        self.v: D = None
        self.t: A = None
        self.txt = txt

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

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

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

n = A("n")
f = B("f")
i = C("i")
j = D("j")
d = E("d")
m = F("m")
g = C("g")

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

class B:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: B = None
        self.v: D = None
        self.t: A = None
        self.txt = txt

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

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

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

n = A("n")
f = B("f")
i = C("i")
j = D("j")
d = E("d")
m = F("m")
g = C("g")

n.u = g
n.o = j
n.w = j
n.x = j
n.y = d
f.t = d
i.r = j
i.v = j
i.w = f
i.t = n
j.w = n
d.p = g
d.z = j
m.u = g
g.r = j
g.v = j
g.w = f
g.t = n
assert m.u.v.w.txt == "n"