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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: F = None
        self.p: C = None
        self.s: A = None
        self.txt = txt

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

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

j.q = e
j.o = d
e.w = d
h.y = k
h.t = k
h.o = j
h.w = g
h.q = d
d.p = g
k.u = c
k.p = h
k.s = g
i.s = k
i.q = d
c.s = k
c.q = d
g.q = e
g.o = d
assert k.u.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: F = None
        self.p: C = None
        self.s: A = None
        self.txt = txt

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

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

j.q = e
j.o = d
e.w = d
h.y = k
h.t = k
h.o = j
h.w = g
h.q = d
d.p = g
k.u = c
k.p = h
k.s = g
i.s = k
i.q = d
c.s = k
c.q = d
g.q = e
g.o = d
assert k.u.s.p.txt == "h"