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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.r: E = None
        self.u: A = None
        self.z: D = None
        self.txt = txt

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

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

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

f = A("f")
m = B("m")
g = C("g")
k = D("k")
h = E("h")
b = A("b")
i = A("i")
j = D("j")
a = C("a")

f.y = a
f.v = j
m.x = k
m.r = h
m.u = b
m.z = j
g.z = f
k.x = i
h.x = f
h.z = j
h.p = j
h.v = i
b.y = g
b.v = k
i.y = g
i.v = j
j.x = f
a.z = b
assert g.z.v.x.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.v: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.r: E = None
        self.u: A = None
        self.z: D = None
        self.txt = txt

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

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

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

f = A("f")
m = B("m")
g = C("g")
k = D("k")
h = E("h")
b = A("b")
i = A("i")
j = D("j")
a = C("a")

f.y = a
f.v = j
m.x = k
m.r = h
m.u = b
m.z = j
g.z = f
k.x = i
h.x = f
h.z = j
h.p = j
h.v = i
b.y = g
b.v = k
i.y = g
i.v = j
j.x = f
a.z = b
assert g.z.v.x.v.x.txt == "f"