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

class B:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: C = None
        self.s: A = None
        self.txt = txt

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

g = A("g")
d = B("d")
j = C("j")
l = A("l")
k = A("k")
h = C("h")
i = C("i")
e = B("e")

g.w = k
d.r = i
d.x = h
d.s = l
j.q = g
j.s = e
j.t = d
l.w = k
k.w = g
h.q = g
h.s = e
h.t = e
i.q = k
i.s = d
i.t = d
e.r = h
e.x = h
e.s = l
assert k.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: C = None
        self.s: A = None
        self.txt = txt

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

g = A("g")
d = B("d")
j = C("j")
l = A("l")
k = A("k")
h = C("h")
i = C("i")
e = B("e")

g.w = k
d.r = i
d.x = h
d.s = l
j.q = g
j.s = e
j.t = d
l.w = k
k.w = g
h.q = g
h.s = e
h.t = e
i.q = k
i.s = d
i.t = d
e.r = h
e.x = h
e.s = l
assert k.w.w.w.w.txt == "k"