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

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

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

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

m = A("m")
n = B("n")
d = C("d")
a = D("a")
j = A("j")
i = D("i")
f = B("f")
c = D("c")
h = B("h")

m.v = f
n.o = d
n.p = d
n.v = m
d.w = f
d.p = a
d.q = i
a.u = d
a.y = n
j.v = n
i.u = d
i.y = f
f.o = d
f.p = d
f.v = m
c.u = d
c.y = n
h.o = d
h.p = d
h.v = m
assert n.v.v.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

m = A("m")
n = B("n")
d = C("d")
a = D("a")
j = A("j")
i = D("i")
f = B("f")
c = D("c")
h = B("h")

m.v = f
n.o = d
n.p = d
n.v = m
d.w = f
d.p = a
d.q = i
a.u = d
a.y = n
j.v = n
i.u = d
i.y = f
f.o = d
f.p = d
f.v = m
c.u = d
c.y = n
h.o = d
h.p = d
h.v = m
assert n.v.v.o.w.txt == "f"