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

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

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

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

e = A("e")
h = B("h")
b = C("b")
j = D("j")
m = D("m")
d = A("d")
i = C("i")
n = A("n")

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

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

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

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

e = A("e")
h = B("h")
b = C("b")
j = D("j")
m = D("m")
d = A("d")
i = C("i")
n = A("n")

e.v = b
e.r = i
h.w = j
h.t = m
h.s = i
b.r = i
b.x = n
j.o = b
j.u = e
m.o = b
m.u = d
d.v = b
d.r = b
i.r = b
i.x = n
n.v = i
n.r = i
assert j.u.v.x.v.r.r.x.v.txt == "i"