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

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

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

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

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

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

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

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

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

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

m.u = e
m.t = b
e.v = c
e.u = d
d.v = n
c.y = n
c.u = m
c.o = h
c.r = e
b.v = c
b.u = d
j.y = n
j.u = m
j.o = h
j.r = e
i.v = h
i.u = n
h.y = n
h.u = m
h.o = j
h.r = e
n.v = d
assert b.u.v.v.v.v.v.v.txt == "d"