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

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

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

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

b.t = h
b.w = e
j.y = g
j.t = b
j.z = l
i.x = g
e.t = l
e.w = b
g.t = h
g.w = e
c.y = b
c.t = e
c.z = j
k.x = g
h.y = g
h.t = g
h.z = j
l.y = b
l.t = e
l.z = j
assert k.x.w.t.t.w.w.t.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.w: A = None
        self.txt = txt

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

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

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

b.t = h
b.w = e
j.y = g
j.t = b
j.z = l
i.x = g
e.t = l
e.w = b
g.t = h
g.w = e
c.y = b
c.t = e
c.z = j
k.x = g
h.y = g
h.t = g
h.z = j
l.y = b
l.t = e
l.z = j
assert k.x.w.t.t.w.w.t.z.y.txt == "g"