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

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

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

n = A("n")
d = B("d")
f = C("f")
h = C("h")
m = B("m")
e = A("e")
j = A("j")

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

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

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

n = A("n")
d = B("d")
f = C("f")
h = C("h")
m = B("m")
e = A("e")
j = A("j")

n.z = d
n.w = j
n.v = m
d.o = e
d.p = j
f.o = n
f.q = e
h.o = n
h.q = n
m.o = e
m.p = e
e.z = m
e.w = j
e.v = d
j.z = m
j.w = n
j.v = d
assert n.w.w.v.txt == "m"