class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.t: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.z: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.u: E = None
        self.w: A = None
        self.q: D = None
        self.txt = txt

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

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

n = A("n")
j = B("j")
d = C("d")
m = D("m")
h = E("h")
c = F("c")
e = D("e")

n.q = j
n.t = c
j.y = m
d.x = n
d.z = c
m.t = d
m.u = h
m.w = n
m.q = e
h.z = c
h.q = e
c.u = m
e.t = d
e.u = h
e.w = n
e.q = m
assert n.t.u.u.q.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.t: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.z: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.u: E = None
        self.w: A = None
        self.q: D = None
        self.txt = txt

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

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

n = A("n")
j = B("j")
d = C("d")
m = D("m")
h = E("h")
c = F("c")
e = D("e")

n.q = j
n.t = c
j.y = m
d.x = n
d.z = c
m.t = d
m.u = h
m.w = n
m.q = e
h.z = c
h.q = e
c.u = m
e.t = d
e.u = h
e.w = n
e.q = m
assert n.t.u.u.q.q.w.q.txt == "j"