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

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

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

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

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

e.z = m
e.y = j
d.v = h
d.x = e
d.p = m
h.q = e
a.x = e
f.x = j
m.q = j
j.z = m
j.y = e
n.v = m
n.x = j
n.p = h
assert h.q.y.y.z.q.y.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: A = None
        self.txt = txt

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

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

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

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

e.z = m
e.y = j
d.v = h
d.x = e
d.p = m
h.q = e
a.x = e
f.x = j
m.q = j
j.z = m
j.y = e
n.v = m
n.x = j
n.p = h
assert h.q.y.y.z.q.y.z.q.txt == "j"