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

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

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

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

h = A("h")
i = B("i")
e = C("e")
g = D("g")
b = B("b")
d = A("d")
j = B("j")
n = A("n")
k = B("k")
f = A("f")

h.v = e
i.t = j
i.v = k
i.r = k
e.x = n
e.u = f
e.o = d
e.y = g
g.w = k
b.t = i
b.r = i
b.v = k
d.v = e
j.t = k
j.v = k
j.r = b
n.v = e
k.t = b
k.v = i
k.r = j
f.v = e
assert k.t.v.t.v.v.r.r.t.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

h = A("h")
i = B("i")
e = C("e")
g = D("g")
b = B("b")
d = A("d")
j = B("j")
n = A("n")
k = B("k")
f = A("f")

h.v = e
i.t = j
i.v = k
i.r = k
e.x = n
e.u = f
e.o = d
e.y = g
g.w = k
b.t = i
b.r = i
b.v = k
d.v = e
j.t = k
j.v = k
j.r = b
n.v = e
k.t = b
k.v = i
k.r = j
f.v = e
assert k.t.v.t.v.v.r.r.t.t.r.txt == "i"