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

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

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

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

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

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

j.w = k
j.r = h
c.z = i
n.z = c
h.z = c
g.w = c
g.r = e
k.z = c
e.z = h
d.z = i
l.w = c
l.r = k
i.z = c
assert n.z.z.z.z.z.z.z.txt == "c"