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

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

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

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

e.x = a
e.z = j
d.x = e
d.v = e
d.r = j
h.y = e
h.v = e
h.x = g
b.y = e
b.x = g
b.v = a
a.x = e
a.z = j
k.x = a
k.v = e
k.r = b
g.x = a
g.v = a
g.r = n
j.y = a
j.v = a
j.x = k
n.y = e
n.x = k
n.v = a
assert k.x.z.y.z.y.z.y.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.z: C = None
        self.txt = txt

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

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

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

e.x = a
e.z = j
d.x = e
d.v = e
d.r = j
h.y = e
h.v = e
h.x = g
b.y = e
b.x = g
b.v = a
a.x = e
a.z = j
k.x = a
k.v = e
k.r = b
g.x = a
g.v = a
g.r = n
j.y = a
j.v = a
j.x = k
n.y = e
n.x = k
n.v = a
assert k.x.z.y.z.y.z.y.x.z.txt == "j"