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

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

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

b = A("b")
k = B("k")
j = C("j")
d = A("d")
l = B("l")
n = C("n")
c = B("c")
e = A("e")
g = C("g")

b.x = g
k.x = c
j.y = l
j.w = g
d.x = g
l.x = k
n.y = c
n.w = j
c.x = l
e.x = j
g.y = k
g.w = n
assert n.y.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

b = A("b")
k = B("k")
j = C("j")
d = A("d")
l = B("l")
n = C("n")
c = B("c")
e = A("e")
g = C("g")

b.x = g
k.x = c
j.y = l
j.w = g
d.x = g
l.x = k
n.y = c
n.w = j
c.x = l
e.x = j
g.y = k
g.w = n
assert n.y.x.x.x.x.x.x.txt == "c"