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

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

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

c = A("c")
a = B("a")
h = C("h")
g = C("g")
b = A("b")
f = A("f")
j = B("j")
e = A("e")

c.q = b
c.w = g
a.r = e
a.w = g
a.y = j
h.t = g
h.y = c
g.t = h
g.y = b
b.q = e
b.w = g
f.q = c
f.w = g
j.r = e
j.w = h
j.y = a
e.q = f
e.w = g
assert a.w.y.w.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: C = None
        self.txt = txt

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

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

c = A("c")
a = B("a")
h = C("h")
g = C("g")
b = A("b")
f = A("f")
j = B("j")
e = A("e")

c.q = b
c.w = g
a.r = e
a.w = g
a.y = j
h.t = g
h.y = c
g.t = h
g.y = b
b.q = e
b.w = g
f.q = c
f.w = g
j.r = e
j.w = h
j.y = a
e.q = f
e.w = g
assert a.w.y.w.t.t.txt == "g"