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

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

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

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.q: B = None
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: D = None
        self.w: A = None
        self.v: D = None
        self.txt = txt

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

h = A("h")
i = B("i")
g = C("g")
d = D("d")
c = E("c")
k = F("k")

h.y = k
h.q = k
h.u = c
i.y = c
i.v = c
i.t = c
i.u = h
g.q = h
g.y = h
d.s = i
d.q = i
d.o = c
c.o = i
c.z = d
c.v = d
c.w = h
k.v = d
assert d.s.u.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: F = None
        self.q: F = None
        self.u: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.q: B = None
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: D = None
        self.w: A = None
        self.v: D = None
        self.txt = txt

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

h = A("h")
i = B("i")
g = C("g")
d = D("d")
c = E("c")
k = F("k")

h.y = k
h.q = k
h.u = c
i.y = c
i.v = c
i.t = c
i.u = h
g.q = h
g.y = h
d.s = i
d.q = i
d.o = c
c.o = i
c.z = d
c.v = d
c.w = h
k.v = d
assert d.s.u.q.v.txt == "d"