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

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: A = None
        self.o: F = None
        self.v: B = None
        self.r: C = None
        self.y: F = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: B = None
        self.u: E = None
        self.q: B = None
        self.txt = txt

h = A("h")
j = B("j")
d = C("d")
l = D("l")
m = E("m")
k = F("k")

h.q = k
h.y = l
j.p = h
d.v = h
l.q = j
l.v = j
l.z = h
l.o = k
l.y = k
l.r = d
m.y = h
m.x = h
m.u = d
k.r = l
k.y = j
k.q = j
k.u = m
assert k.u.y.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: F = None
        self.y: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: A = None
        self.o: F = None
        self.v: B = None
        self.r: C = None
        self.y: F = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: B = None
        self.u: E = None
        self.q: B = None
        self.txt = txt

h = A("h")
j = B("j")
d = C("d")
l = D("l")
m = E("m")
k = F("k")

h.q = k
h.y = l
j.p = h
d.v = h
l.q = j
l.v = j
l.z = h
l.o = k
l.y = k
l.r = d
m.y = h
m.x = h
m.u = d
k.r = l
k.y = j
k.q = j
k.u = m
assert k.u.y.y.z.txt == "h"