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

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

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

h = A("h")
l = B("l")
j = C("j")
n = B("n")
d = B("d")
g = B("g")
k = B("k")
e = C("e")
m = C("m")

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

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

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

h = A("h")
l = B("l")
j = C("j")
n = B("n")
d = B("d")
g = B("g")
k = B("k")
e = C("e")
m = C("m")

h.x = e
h.y = n
h.t = l
l.x = k
l.r = e
j.y = l
j.v = e
n.x = l
n.r = e
d.x = g
d.r = m
g.x = l
g.r = e
k.x = l
k.r = j
e.y = d
e.v = j
m.y = k
m.v = e
assert k.x.x.x.r.y.txt == "d"