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

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

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

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

m = A("m")
f = B("f")
e = C("e")
d = D("d")
h = B("h")
b = D("b")
g = B("g")

m.v = g
m.r = h
f.r = b
f.s = b
e.y = b
d.r = b
d.z = e
d.u = m
d.o = m
h.r = b
h.s = b
b.r = d
b.z = e
b.u = m
b.o = m
g.r = d
g.s = d
assert d.u.v.r.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: B = None
        self.txt = txt

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

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

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

m = A("m")
f = B("f")
e = C("e")
d = D("d")
h = B("h")
b = D("b")
g = B("g")

m.v = g
m.r = h
f.r = b
f.s = b
e.y = b
d.r = b
d.z = e
d.u = m
d.o = m
h.r = b
h.s = b
b.r = d
b.z = e
b.u = m
b.o = m
g.r = d
g.s = d
assert d.u.v.r.r.u.txt == "m"