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

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.p: F = None
        self.s: A = None
        self.q: F = None
        self.t: B = None
        self.y: F = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.s: D = None
        self.p: B = None
        self.y: E = None
        self.z: E = None
        self.w: B = None
        self.o: C = None
        self.txt = txt

d = A("d")
e = B("e")
g = C("g")
n = D("n")
m = E("m")
k = F("k")
f = A("f")

d.u = e
d.p = n
d.y = n
d.z = k
e.y = g
g.x = m
n.u = d
n.p = k
n.q = k
n.y = k
n.s = f
n.t = e
m.t = g
k.s = n
k.p = e
k.w = e
k.y = m
k.z = m
k.o = g
f.u = e
f.p = n
f.y = n
f.z = k
assert n.q.y.t.x.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.p: D = None
        self.z: F = None
        self.y: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.p: F = None
        self.s: A = None
        self.q: F = None
        self.t: B = None
        self.y: F = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.s: D = None
        self.p: B = None
        self.y: E = None
        self.z: E = None
        self.w: B = None
        self.o: C = None
        self.txt = txt

d = A("d")
e = B("e")
g = C("g")
n = D("n")
m = E("m")
k = F("k")
f = A("f")

d.u = e
d.p = n
d.y = n
d.z = k
e.y = g
g.x = m
n.u = d
n.p = k
n.q = k
n.y = k
n.s = f
n.t = e
m.t = g
k.s = n
k.p = e
k.w = e
k.y = m
k.z = m
k.o = g
f.u = e
f.p = n
f.y = n
f.z = k
assert n.q.y.t.x.t.x.txt == "m"