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

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

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

c = A("c")
g = B("g")
n = C("n")
e = B("e")
a = A("a")
j = A("j")
h = B("h")
k = A("k")

c.w = e
c.x = k
g.x = j
n.r = a
e.x = k
a.w = e
a.x = k
j.w = e
j.x = a
h.x = c
k.w = e
k.x = j
assert c.w.x.x.x.w.x.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: A = None
        self.txt = txt

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

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

c = A("c")
g = B("g")
n = C("n")
e = B("e")
a = A("a")
j = A("j")
h = B("h")
k = A("k")

c.w = e
c.x = k
g.x = j
n.r = a
e.x = k
a.w = e
a.x = k
j.w = e
j.x = a
h.x = c
k.w = e
k.x = j
assert c.w.x.x.x.w.x.w.x.txt == "k"