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

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

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

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

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

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

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

f.y = k
f.w = e
k.w = m
k.y = m
k.s = j
m.q = k
m.o = j
m.w = f
d.u = f
d.q = k
e.s = j
e.r = f
e.y = f
e.q = k
j.s = d
j.o = f
assert j.s.u.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: E = None
        self.txt = txt

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

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

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

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

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

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

f.y = k
f.w = e
k.w = m
k.y = m
k.s = j
m.q = k
m.o = j
m.w = f
d.u = f
d.q = k
e.s = j
e.r = f
e.y = f
e.q = k
j.s = d
j.o = f
assert j.s.u.w.q.txt == "k"